0
Alien head

Android App Development Test - 2

Description: Android App Development Test-2
Number of Questions: 15
Created by:
Tags: Android App Development Test-2 Android
Attempted 0/15 Correct 0 Score 0

Android 2.3 introduced a new developer tool called __________. This tool detects disk or network operations occurring on the main thread and takes action to warn the developer.

  1. SMode

  2. StrictMode

  3. DetectMode

  4. DetectAll()


Correct Option: B
Explanation:

Android 2.3 introduced a new developer tool called StrictMode. This tool detects disk or network operations occurring on the main thread and takes action to warn the developer.

What is the purpose of Handler class in android?

  1. This allows us to send message to be processed immediately only.

  2. This allows us to send messages can be processed at some time in the future only.

  3. This allows us to send messages which can be processed immediately or scheduled for processing at some time in the future.

  4. None of the above


Correct Option: C
Explanation:

A handler class allows you to send messages which are to be processed by the handler at some other time or immediately.

The _________ class creates and manages a MessageQueue object that holds all messages for a thread.

  1. loader

  2. looper

  3. handler

  4. load


Correct Option: B
Explanation:

The looper class creates and manages a MessageQueue object that holds all messages for a thread.

The looper class creates and manages a______________ object that holds all messages for a thread.

  1. QueueMessage

  2. Handler

  3. MessageThread

  4. MessageQueue


Correct Option: D
Explanation:

The looper class creates and manages a MessageQueue object that holds all messages for a thread.

Which of the following is not a valid screen pixel density?

  1. ldpi

  2. mdpi

  3. hdpi

  4. xdpi


Correct Option: D
Explanation:

xhdpi is a valid screen pixel density whereas xdpi is not a valid screen pixel density.

Which of the following is the correct way to declare StrictMode that detects all types of networks and disk I/O?

  1. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyLog()
    .penaltyDialog()
    .build());
    
  2. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyLog()
    .penaltyDeath()
    .build());
    
  3. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyLog()
    .penaltyDialog()
    );
    
  4. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyDialog()
    .build());
    

Correct Option: A
Explanation:

Simple StrictMode declaration that detects all types of network and disk I/O:

StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
 .detectAll()
 .penaltyLog()
 .penaltyDialog().build());

How can we create a method that checks for messages in the message queue?

  1. Public Boolean isTimerRunn(){
         Return mHandler.hasMessages(0);
    }
    
  2. Private Boolean isTimerRunn(){
         Return mHandler.hasMessages(0);
    }
    
  3. Private Boolean is TimerRunn(){
         Return mHandler.hasMessages(0);
    }
    
  4. Private Boolean isTimerRunn(){
         Return mHandler.queueMessages(0);
    }
    

Correct Option: B
Explanation:

The method that checks for messages in the message queue can be defined as follows:

Private Boolean isTimerRunn() {
 Return mHandler.hasMessages(0);
}

In contrast to ________, android doesn’t know the size, screen resolution or aspect ratio of the devices they run on.

  1. Android devices

  2. IOS devices

  3. Blackberry devices

  4. Microsoft


Correct Option: B
Explanation:

In contrast to IOS devices, Android doesn’t know the size, screen resolution or aspect ratio of the devices they run on.

How many types of screen sizes are there in the configuration option of android?

  1. Small, normal, and large

  2. Small, normal, large, and xlarge

  3. Small, medium,and large

  4. Small, medium, large, and xlarge


Correct Option: B
Explanation:

There are four types of screen sizes in the configuration option of android:

Small

Normal
Large Xlarge

Which of the following is not a Android dimension units?

  1. mm

  2. pt

  3. dip

  4. cp


Correct Option: D
Explanation:

There are six valid Android dimension units:

px: pixels

in:inches
mm: milimeters
pt:points
dip:density independent pixels
sp:scaled pixel cp is not a valid Android dimension units.

Which of the following statement is/are correct? A. dip is an abstract unit representing a single pixel on a device with a resolution of 160 dpi. B. pt unit are the 1/75 of the physical screen size.

  1. Only A

  2. Only B

  3. Both A and B

  4. Neither A nor B


Correct Option: A
Explanation:

dip(Density independent pixels) is an abstract unit representing a single pixel on a device with a resolution of 160 dpi but the pt(Points) unit are the 1/72 of the physical screen size.

Which of the following classes can be extended to create a simple thread to perform background tasks and publish the results on the UI thread?

  1. Async

  2. AsyncBackgroundTask

  3. AsyncTask

  4. SyncTask


Correct Option: C
Explanation:

We can extend the AsyncTask class to create a simple thread to perform background tasks and publish the results on the UI thread.

Which of the following codes will record the current system time and send a message to the handler starting the timer and remove any existing message before sending the next one?

  1. Private void startTimer(){
       mSt=System.currentTimeMillis();
       mHandler.removeMessages(0);
       mHandler.sendEmptyMessage(0);
    }
    
  2. Private void startTimer(){
       mSt=System.currentTime();
       mHandler.removeMessages(0);
       mHandler.sendEmptyMessage(0);
    }
    
  3. Private void startTimer(){
       mSt=System.currentTimeMillis();
       mHandler.removeMessage(0);
       mHandler.sendEmptyMessage(0);
    }
    
  4. Private void startTimer(){
       mSt=System.currentTimeMillis();
       mHandler.removeMessages(0);
       mHandler.sendEmptyMessages(0);
    }
    

Correct Option: A
Explanation:

The code for recording the current system time and sending a message to the handler, starting the timer and removing any existing messages before sending the next one is as follows:

Private void startTimer() {
 mSt = System.currentTimeMillis();
 mHandler.removeMessages(0);
 mHandler.sendEmptyMessage(0);
}

Which of the following classes is useful in a situation like downloading new posts from Twitter and then loading those posts into a timeline?

  1. AsyncTask

  2. Loader

  3. Handler

  4. MessageQueue


Correct Option: A
Explanation:

AsyncTask class is useful in a situation like downloading new posts from Twitter and then loading those posts into a timeline.

List the point which makes your app compatible with majority of the devices: A. Always use dip unit in your layout. B. Use wrap_content and match_parent whenever possible. C. Provide alternative image resources for each density . D. Use 9-patch graphics for any resources. E. Always use sp unit in your layout.

  1. B, C, D, E

  2. A, B, C, E

  3. A, B, C, D

  4. A, C, D, E


Correct Option: C
Explanation:

Remember these points, which makes your app compatible with majority of the devices:

Always use dip unit in your layout.

Use wrap_content and match_parent whenever possible.This will make your layout much more flexible than layouts using hard-coded dimension values.
Provide alternative image resources for each densit to ensure that your images look appropriate on all screen densities. .
Use 9-patch graphics for any resources that can’t stretch without distortion. Always use sp unit in your layout.

+ View questions