Showing posts with label Mobile App. Show all posts
Showing posts with label Mobile App. Show all posts

What invokes a scheduled Timer?

What invokes a scheduled Timer? 


a. AbstractTask
b. ScheduledTask
c. Task
d. TimerTask


Answer: d. TimerTask

What does the splash screen provide time for Android to do?

What does the splash screen provide time for Android to do? 


a. bootstrap the phone driver
b. download updates
c. initialize resources for your app
d. stream data from Google


Answer: c. initialize resources for your app

What is printed to the console after the code that follows is executed?

What is printed to the console after the code that follows is executed?

int[][] types = new int[4][];
for (int i = 0; i < types.length; i++)
{
types[i] = new int[i+1];
}
System.out.println(types[1].length);

a. "3"
b. code doesn't compile
c. "1"
d. "4"
e. "2"


Answer: e. "2"

What happens when the code that follows is executed?

What happens when the code that follows is executed?

int[] nums = new int[4];
for (int i = 0; i <= nums.length; i++)
{
nums[i] = i;
}
System.out.println(nums[2]);

a. It prints "3" to the console.
b. It prints "2" to the console.
c. It prints "1" to the console.
d. It throws an ArrayIndexOutOfBoundsException


Answer: d. It throws an ArrayIndexOutOfBoundsException

What is the length of the bestTimes array?

double[] times = {3.56, 3.9, 2.6, 4.5, 2.4, 5.2};
double[] bestTimes = new double[4];
Arrays.sort(times);
bestTimes = Arrays.copyOfRange(times, 1, 4);

What is the length of the bestTimes array?


a. 4
b. 3
c. 6
d. 5


Answer: a. 4

An enhanced for loop can only be used

An enhanced for loop can only be used


a. to work with one-dimensional arrays
b. to work with all the elements of an array
c. to work with jagged arrays
d. to work with arrays that contain integers


Answer: b. to work with all the elements of an array

Which of the following is not a reason to create a package?

Which of the following is not a reason to create a package?


a. To group related classes
b. To make finding classes easier
c. To make it easy to reuse classes
d. To prevent other developers from using the class


Answer: d. To prevent other developers from using the class

Which of the following is a valid Javadoc comment?

Which of the following is a valid Javadoc comment?


a. // Calculates the balance due //
b. / Calculates the balance due */
c. /* Calculates the balance due /
d. / Calculates the balance due /


Answer: c. /* Calculates the balance due /