1.What is the output of the following statements? Select one: a. Cal, Bob, Ann b
ID: 3685239 • Letter: 1
Question
1.What is the output of the following statements?
Select one:
a. Cal, Bob, Ann
b. Ann, Bob
c. Ann, Cal, Tony
d. Array list bound error
2.Consider the following 2-dimensional array. Select the statement that gives the number of columns in the third row.
Select one:
a. int cols = counts[2].size();
b. int cols = counts.length[2];
c. int cols = counts.length;
d. int cols = counts[2].length;
3.
Consider the following code snippet:
Identify the appropriate statement to display the value 24 from the given array?
Select one:
a. System.out.println(arr[1][2]);
b. System.out.println(arr[2][2]);
c. System.out.println(arr[1][1]);
d. System.out.println(arr[2][1]);
4.
Consider the following line of code for calling a method named func1:
Which one of the following method headers is valid for func1, where listData is an integer array list and varData is an integer variable?
Select one:
a. public static void func1(int[] listData, int varData)
b. public static void func1(ArrayList<Integer> listData, varData)
c. public static void func1(ArrayList<Integer> ldata, int vdata)
d. public static void func1(int vdata, ArrayList<Integer> ldata)
5.
Which one of the following code snippets accepts the integer input in an array list named num1 and stores the even integers ofnum1 in another array list named evennum?
Select one:
a.
b.
c.
d.
6.
Which one of the following statements is correct for displaying the value in the second row and the third column of a two-dimensional, size 3 by 4 array?
Select one:
a. System.out.println(arr[1][2]);
b. System.out.println(arr[2][3]);
c. System.out.println(arr[2][1]);
d. System.out.println(arr[3][2]);
7.
Select the statement that reveals the logic error in the following method.
Select one:
a. double m = minimum(new double[] { 1.2, -3.5, 6.6, 2.4 });
b. double m = minimum(new double[] { 1.2, 23.5, 16.6, -23.4 });
c. double m = minimum(new double[] { -10.2, 3.5, 62.6, 21.4 });
d. double m = minimum(new double[] { 12.2, 31.5, 6.6, 2.4 });
8.
What is the result of executing this code snippet?
Select one:
a. The code snippet does not give any output.
b. The code snippet displays all the marks stored in the array without any redundancy.
c. The code snippet causes a bounds error.
d. The code snippet executes an infinite loop.
9.
Is there any thing wrong with the following code snippet?
Select one:
a. There is nothing wrong.
b. There is compile-time error.
c. There is a bounds error.
d. There is a logic error.
Explanation / Answer
1)
d. Array list bound error
2)
d. int cols = counts[2].length;
3)
c. System.out.println(arr[1][1]);
4)
a. public static void func1(int[] listData, int varData)
5)
a.
ArrayList<Integer> num1 = new ArrayList<Integer>();
ArrayList<Integer> evennum = new ArrayList<Integer>();
Scanner in = new Scanner(System.in);
int data;
for (int i = 0; i < 10; i++)
{
data = in.nextInt();
num1.add(data);
if (num1.get(i) % 2 == 0)
{
evennum.add(num1.get(i));
}
}
6)
a. System.out.println(arr[1][2]);
7)
d. double m = minimum(new double[] { 12.2, 31.5, 6.6, 2.4 });
8)
c. The code snippet causes a bounds error.
9)
d. There is a logic error.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.