Android Activity and Intents - questions and answers

Android Activity and Intents - questions and answers


Q.1 Choose the correct option regarding activity in android.

A) An activity is a window that contains the user interface of your application.
B) An application can have zero or more activities.
C) An application can have only one activity.
D) Option A and B are correct.

View Answer / Hide Answer

ANSWER: D




Q.2 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?

A) Intent intent=new Intent (this, ActivityTwo.class);
startActivity(intent);
B) startActivity(new Intent(this, ActivityTwo.class));
C) Option A and B are correct.
D) None of the above.

View Answer / Hide Answer

ANSWER: C




Q.3 What is the permission for using the camera?

A. android.permission.USE_CAMERA
B. android.permission.CAMERA
C. android.permission.hardware.CAMERA
D) None of the above.

View Answer / Hide Answer

ANSWER: B




Q.4 The Log class supports which log types?

A) Error
B) Warning
C) Debug
D) All of the above.

View Answer / Hide Answer

ANSWER: D




Q.5 If you need to pass data back from an activity, Which method you should use?

A) startActivity()
B) startActivityForResult()
C) ActivityForResult()
D) None of the above.

View Answer / Hide Answer

ANSWER: B




Q.6 If you want to navigate from one activity to another then android provides you which class?

A) Object
B) startActivity
C) Intent
D) None of the above.

View Answer / Hide Answer

ANSWER: C




Q.7 The types of intents in android is\are

A) Explicit intents
B) Implicit intents
C) Start intents
D) Option A and B are correct.

View Answer / Hide Answer

ANSWER: D




Q.8 In android mini-activities are also known as.

A) Adapter
B) Activity
C) Fragments
D) None of the above.

View Answer / Hide Answer

ANSWER: C




Q.9 How will you reference a textbox control in java file, that is available in XML file and the ID is txtName.

A) EditText txtEmpName;
txtEmpName=findViewById(R.id.txtName);
B) EditText txtEmpName;
txtEmpName=(EditText)findViewById(R.id.txtName);
C) EditText txtEmpName;
txtEmpName=(EditText)findViewById(txtName);
D) None of the above.

View Answer / Hide Answer

ANSWER: B




Q.10 Suppose that there are two activities in an application named FirstActivity and SecondActivity. You want to send website name from ActivityOne to ActivityTwo. What code you will write? Suppose that website name is “CareerRide.com”

A) Intent intent=new Intent (this, SecondActivity.class);
intent.putExtra("name", “CareerRide.com”);
startActivity(intent);

B) Intent intent=new Intent (this, SecondActivity.class);
intent.putExtra( “CareerRide.com”);
startActivity(intent);

C) Intent intent=new Intent ();
intent.putExtra("name", “CareerRide.com”);
startActivity(intent);

D) None of the above.

View Answer / Hide Answer

ANSWER: A




Q.11 How will you get the data in secondActivity? Refer question 10.

A) Intent intent=new Intent;
String str= intent.getStringExtra("name");
Toast.makeText(this, str , Toast.LENGTH_LONG).show();

B) Intent intent=getIntent();
String str= intent.getStringExtra("name");
Toast.makeText(this, str , Toast.LENGTH_LONG).show();

C) Intent intent=getIntent();
String str= intent.getText("name");
Toast.makeText(this, str , Toast.LENGTH_LONG).show();

D) None of the above.

View Answer / Hide Answer

ANSWER: B




Q.12 For creating Fragments the java class needs to extend which base class?

A) MainActivity
B) MiniActivity
C) Fragment
D) None of the above.

View Answer / Hide Answer

ANSWER: C



Post your comment