Lab 5 Self-Assessment

Lab 5 Self-Assessment

Q1 There are four different types of app component in an Android app.  Which one of these app components do not require Intent to activate it?

Answer

Activity

Services

Broadcast Receivers

Content Providers




Answer:           Content Providers


 Q2 Every Android app would have a Android Manifest file, which does the following except

Answer

Defines the GUI of the MainActivity of the app

Specifies any user permissions the app requires

Declares the Activity that is to be run during the launch of the app.

Declares hardware and software features used or required by the app



Answer:   Defines the GUI of the MainActivity of the app



Q3 When the battery of an Android device is low, which of the following app component will be used to inform the user of the battery status?

Answer

Activity

Services

Broadcast Receivers

Content Providers


Answer:  Broadcast Receivers


Question options:

Q4  In your MainActivity of an Android app, you would like to load another activity, named "SecondActivity" by clicking on a button. Fill in the blanks for the following code snippets from MainActivity.java.

public class MainActivity extends Activity {

                protected void onCreate(Bundle savedInstanceState) {

                                super.onCreate(savedInstanceState);

                                setContentView(R.layout.activity_main);

                                Button myButton = (Button)findViewById(R.id.my_button);

                                myButton.setOnClickListener(new OnClickListener() { 

public void onClick(View v) {

                                                Intent msg  = new Intent(MainActivity.this, ____________________);

                                                _________________(msg); 

                                   }

                                } );

                }

   }




Answer:

Q5 In your MainActivity of an Android app, you would like to load another activity, named "SecondActivity" by clicking on a button. Fill in the blanks for the following code snippets from MainActivity.java.

public class MainActivity extends Activity {

                protected void onCreate(Bundle savedInstanceState) {

                                super.onCreate(savedInstanceState);

                                setContentView(R.layout.activity_main);

                                Button myButton = (Button)findViewById(R.id.my_button);

                                myButton.setOnClickListener(new OnClickListener() { 

public void onClick(View v) {

                                                Intent msg  = new Intent(MainActivity.this, ____________________);

                                                _________________(msg); 

                                   }

                                } );

                }

   }


Q6   What is the Android Application Component used to provide background tasks?

Answer

Service

Activity

Content Provider

Broadcast Receiver



Answer:                 Service

 

Q7

Suppose that there are two activities in an application named ActivityOne and ActivityTwo. You want to invoke ActivityTwo from ActivityOne. What code you will write? (There is more than 1 answer)

Answer

Intent intent=new Intent (this, ActivityTwo.class);

startActivity(intent);

startActivity(new Intent(this, ActivityTwo.class));

Intent intent=new Intent (ActivityTwo.class);

startActivity(intent);

Intent intent=new Intent (ActivityOne.class);

startActivity(intent);



Answer:  



Intent intent=new Intent (this, ActivityTwo.class);

                startActivity(intent);


startActivity(new Intent(this, ActivityTwo.class));


Q8

If you want to navigate from one activity to another activity, which android class would you use to do that? 

Answer

Object

MainActivity

Intent

Context



Answer:   Intent




Q9

Suppose that there are two activities in an application named FirstActivity and SecondActivity. You want to send website name from the FirstActivity to the SecondActivity. What code you will write? Suppose that website name is "CareerRide.com" 

Answer

Intent intent=new Intent (this, SecondActivity.class);

intent.putExtra("name", "CareerRide.com");

startActivity(intent);

Intent intent=new Intent (this, SecondActivity.class);

intent.putExtra( "CareerRide.com");

startActivity(intent);

Intent intent=new Intent ();

intent.putExtra("name", "CareerRide.com");

startActivity(intent);

Intent intent=new Intent (this, FirstActivity.class);

intent.putExtra("name", "CareerRide.com");

startActivity(intent);



Answer:

Intent intent=new Intent (this, SecondActivity.class);

intent.putExtra("name", "CareerRide.com");

startActivity(intent);



Q10


What are the files that are stored in the res/values folder of the Android app in Android Studio?  (Choose all that apply)

Answer

strings.xml

colors.xml

styles.xml

activity_main.xml


Answer:   all correct except activity_main.xml




Q11

Which of the following layout in android aligns all children either vertically or horizontally?

Answer

RelativeLayout

TableLayout

FrameLayout

LinearLayout



Answer:  LinearLayout



Comments

Popular posts from this blog

Simple Login Example (PHP Server + Android Client)

Lab 6: Using split