MULTIPLE CHOICE. Choose the one alternative that best

advertisement
Exam
Name___________________________________
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or
answers the question.
1) You can always convert a while loop to a for loop.
1) _______
A) true
B) false
2) Will the following program terminate?int balance = 10;while (true) {
if (balance < 9) break; balance = balance - 9;}
A) Yes
2) _______
B) No
3) You can always write a program without using break or continue in a
loop.
A) true
B) false
3) _______
4) What is sum after the following loop terminates?int sum = 0;int item =
0;do { item++; sum += item; if (sum >= 4) continue;}while (item < 5);
4) _______
A) 18
B) 16
C) 15
D) 17
5) Analyze the following code.int count = 0;while (count < 100) {
A System.out.println("Welcome to Java!");
count++;
B}
// Point C
// Point
// Point
5) _______
(choose all that apply)
A) count < 100 is always false at Point C
B) count < 100 is always false at Point B
C) count < 100 is always true at Point C
D) count < 100 is always true at Point A
E) count < 100 is always true at Point B
6) Is the following loop correct?for (; ; );
A) Yes
6) _______
B) No
7) What is sum after the following loop terminates?int sum = 0;int item =
0;do { item++; sum += item; if (sum > 4) break;}while (item < 5);
A) 7
B) 8
C) 6
D) 5
8) How many times will the following code print "Welcome to Java"?int
count = 0;do { System.out.println("Welcome to Java");} while (count++
< 10);
A) 11
B) 9
C) 0
7) _______
D) 10
8) _______
E) 8
9) To add 0.01 + 0.02 + ... + 1.00, what order should you use to add the
numbers to get better accuracy?
A) add 1.00, 0.99, 0.98, ..., 0.02, 0.01 in this order to a sum variable
whose initial value is 0.
B) add 0.01, 0.02, ..., 1.00 in this order to a sum variable whose initial
9) _______
value is 0.
10) What is the number of iterations in the following loop:
<= n; i++) {
// iteration
}
A) n + 1
B) n - 1
for (int i = 1; i
C) 2*n
10) ______
D) n
11) Analyze the following statement:double sum = 0;for (double d = 0;
d<10;) { d += 0.1;
sum += sum + d;}
11) ______
A) The program has a syntax error because the adjustment is missing
in the for loop.
B) The program runs in an infinite loop because d<10 would always
be true.
C) The program has a syntax error because the control variable in the
for loop cannot be of the double type.
D) The program compiles and runs fine.
12) Analyze the following fragment:double sum = 0;double d = 0;while
(d != 10.0) {
d += 0.1;
sum += sum + d;}
12) ______
A) After the loop, sum is 0 + 0.1 + 0.2 + 0.3 + ... + 1.9
B) The program may not stop because of the phenomenon referred to
as numerical inaccuracy for operating with floating-point numbers.
C) The program does not compile because sum and d are declared
double, but assigned with integer value 0.
D) The program never stops because d is always 0.1 inside the loop.
13) What is 1.0 + 1.0 + 1.0 == 3.0?
A) true
B) false
C) There is no guarantee that 1.0 + 1.0 + 1.0 == 3.0 is true.
13) ______
14) What is the output of the following fragment? for (int i = 0; i < 15; i++)
{ if (i % 4 == 1)
System.out.print(i + " ");
}
14) ______
A)
B)
C)
D)
E)
1 5 9 13 16
1 4 8 12
1 3 5 7 9 11 13
1 3 5 7 9 11 13 15
1 5 9 13
15) What is y after the following for loop statement is executed?int y = 0;for
(int i = 0; i < 10; ++i) {
y += 1; }
A) 10
B) 9
C) 11
16) What the output of the following code:for ( ; false ; )
System.out.println("Welcome to Java");
A) prints out Welcome to Java one time.
B) prints out Welcome to Java two times.
15) ______
D) 12
16) ______
C) does not print anything.
D) prints out Welcome to Java forever.
17) After the continue outer statement is executed in the following loop,
which statement is executed?
outer: for (int i = 1; i < 10; i++) {
inner:
for (int j = 1; j <
10; j++) {
if (i * j > 50)
continue outer;
System.out.println(i * j);
} } next:
A) The program terminates.
B) The control is in the inner loop, and the next iteration of the inner
loop is executed.
C) The control is in the outer loop, and the next iteration of the outer
loop is executed.
D) The statement labeled next.
17) ______
18) Will the following program terminate?int balance = 10;while (true) {
if (balance < 9) continue;
balance = balance - 9;}
18) ______
A) Yes
B) No
19) What is the output for y?int y = 0;for (int i = 0; i<10; ++i) {
i; }System.out.println(y);
A) 13
B) 45
C) 11
D) 10
y +=
E) 12
20) What is the output of the following fragment?int i = 1;int j = 1;while (i <
5) {
i++;
j = j * 2;}System.out.println(j);
A) 16
B) 8
C) 4
D) 32
B) 9
C) 11
D) 0
B) 0
C) 8
D) 9
21) ______
E) 10
22) How many times will the following code print "Welcome to Java"?int
count = 0;while (count < 10) { System.out.println("Welcome to Java");
count++;}
A) 11
20) ______
E) 64
21) What is the value in count after the following loop is executed?int count
= 0;do { System.out.println("Welcome to Java");} while (count++ <
9);System.out.println(count);
A) 8
19) ______
22) ______
E) 10
23) After the break outer statement is executed in the following loop, which
statement is executed?
outer: for (int i = 1; i < 10; i++) {
inner:
for (int j = 1; j <
10; j++) {
if (i * j > 50)
break
outer;
System.out.println(i * j);
}
} next:
A) The program terminates.
B) The statement labeled inner.
C) The statement labeled outer.
D) The statement labeled next.
24) Assume x is 0. What is the output of the following statement?if (x > 0)
printf("x is greater than 0");else if (x < 0)
printf("x is less than
0");else printf("x equals 0");
23) ______
24)
______
A) x equals 0
C) x is less than 0
B) x is greater than 0
D) None
25) What balance after the following code is executed?int balance = 10;while
(balance >= 1) { if (balance < 9) continue;
balance = balance - 9;}
A)
B)
C)
D)
E)
25) ______
1
The loop does not end
2
-1
0
26) What is Math.round(3.6)?
A) 3.0
B) 4.0
26) ______
C) 4
D) 3
27) ________ is a simple but incomplete version of a method.
A) A main method
B) A stub
C) A method developed using top-down approach
D) A non-main method
27) ______
28) Which of the following is a possible output for (int)(51 *
Math.random())? (choose all that apply)
A) 0
B) 50
C) 500
28) ______
D) 100
29) Analyze the following code.public class Test { public static void
main(String[] args) {
System.out.println(m(2));
}
public static int m(int num) {
return num;
}
public
static void m(int num) {
System.out.println(num);
}}
29) ______
A) The program runs and prints 2 once.
B) The program has a syntax error because the second m method is
defined, but not invoked in the main method.
C) The program runs and prints 2 twice.
D) The program has a syntax error because the two methods m have
the same signature.
30) What is Math.floor(3.6)?
A) 5.0
B) 4
30) ______
C) 3.0
D) 3
31) Does the method call in the following method cause syntax
errors?public static void main(String[] args) {
Math.pow(2, 4);}
A) Yes
B) No
32) Suppose static void nPrint(String message, int n) {
while (n > 0) {
System.out.print(message);
n--;
}}What is the printout
of the call nPrint('a', 4)?
A) aaa
C) aaaaa
31) ______
B) aaaa
D) invalid call
32) ______
33) Which of the following method results in 8.0? (choose all that apply)
A) Math.rint(8.5)
B) Math.ceil(8.5)
C) Math.round(8.5)
D) Math.floor(8.5)
33) ______
34) A method can be defined inside a method in Java.
A) true
B) false
34) ______
35) Math.floor(5.5) evaluates to ________.
A) 5
B) 6
C) 5.0
D) 6.0
35) ______
36) Math.ceil(5.5) evaluates to ________.
A) 6
B) 6.0
C) 5.0
D) 5
36) ______
37) Suppose static void nPrint(String message, int n) {
while (n > 0) {
System.out.print(message);
n--;
}}What is k after
invoking nPrint("A message", k)?int k = 2;nPrint("A message", k);
A) 0
B) 2
C) 3
37) ______
D) 1
38) Analyze the following code:class Test { public static void main(String[]
args) { System.out.println(xMethod((double)5));
}
public
static int xMethod(int n) {
System.out.println("int");
return n;
}
public static long xMethod(long n) {
System.out.println("long");
return n;
}}
A) The program displays long followed by 5.
B) The program displays int followed by 5.
C) The program runs fine but displays things other than given in A
and B.
D) The program does not compile.
38) ______
39) You can define two methods in the same class with the same name and
parameter list.
A) true
B) false
39) ______
40) Which of the following should be declared as a void method?
A) Write a method that checks whether current second is today is
integers from 1 to 100.
B) Write a method that returns a random integer from 1 to 100.
C) Write a method that converts an uppercase letter to lowercase.
D) Write a method that prints integers from 1 to 100.
40) ______
41) A variable defined inside a method is referred to as ________.
A) a local variable
B) a block variable
C) a global variable
D) a method variable
41) ______
42) Each time a method is invoked, the system stores parameters and local
variables in an area of memory, known as ________, which stores
elements in last-in first-out fashion.
A) a stack
B) storage area
C) a heap
D) an array
42) ______
43) ________ is to implement one method in the structure chart at a time
fro m the
top to
the
bottom.
43)
A)
B)
C)
D)
___
___
Bottom-up and top-down approach
Bottom-up approach
Top-down approach
Stepwise refinement
44) Analyze the following code:public class Test { public static void
main(String[] args) {
int[] oldList = {1, 2, 3, 4, 5};
reverse(oldList);
for (int i = 0; i < oldList.length; i++)
System.out.print(oldList[i] + " "); }
public static void
reverse(int[] list) {
int[] newList = new int[list.length];
for (int i = 0; i < list.length; i++)
newList[i] =
list[list.length - 1 - i];
list = newList; }}
44) ______
A) The program displays 1 2 3 4 5 and then raises an
ArrayIndexOutOfBoundsException.
B) The program displays 5 4 3 2 1 and then raises an
ArrayIndexOutOfBoundsException.
C) The program displays 1 2 3 4 5.
D) The program displays 5 4 3 2 1.
45) The array size is specified when the array is declared.
A) true
B) false
45) ______
46) Analyze the following code.public class Test { public static void
main(String[] args) {
int[] x = new int[3];
System.out.println("x[0] is " + x[0]);
}}
46) ______
A) The program has a runtime error because the array element x[0] is
not defined.
B) The program has a runtime error because the array elements are
not initialized.
C) The program has a syntax error because the size of the array
wasn't specified when declaring the array.
D) The program runs fine and displays x[0] is 0.
47) Consider the following statements:int[] numbers = new int[10];int[]
numbers = new int[5];What is numbers.length?
A) 10.
B) 5
C) undefined.
D) The above statements are illegal.
47) ______
48) Show the output of the following code:public class Test { public static
void main(String[] args) {
int[] x = {1, 2, 3, 4, 5};
increase(x);
int[] y = {1, 2, 3, 4, 5};
increase(y[0]);
System.out.println(x[0] + " " + y[0]); }
public static void
increase(int[] x) {
for (int i = 0; i < x.length; i++)
x[i]++;
}
public static void increase(int y) {
y++; }}
48) ______
A) 2 2
B) 0 0
C) 1 1
D) 2 1
E) 1 2
49) Given the following statement
int[ ] list = new int[10];
list.length has the value
A) 9
B) 11
C) 10
D) The value depends on how many integers are stored in list.
49) ______
50) Given the following declaration:
int[ ][ ] m = new int[5][6];
Which of the following statements is true?
A) The name m represents a two-dimensional array of 30 int values.
B) m[2][4] represents the element stored in the 2nd row and the 4th
column of m.
C) m[0].length has the value 5.
D) m.length has the value 6.
50) ______
51) Analyze the following code:public class Test { public static void
main(String[] args) {
final int[] x = {1, 2, 3, 4};
int[] y = x;
x = new int[2];
for (int i = 0; i <
y.length; i++)
System.out.print(y[i] + " ");
}}
51) ______
A) The program displays 0 0
B) The program has a syntax error on the statement x = new int[2],
because x is final and cannot be changed.
C) The program displays 1 2 3 4
D) The elements in the array x cannot be changed, because x is final.
52) Analyze the following code:public class Test1 { public static void
main(String[] args) {
xMethod(new double[]{3, 3});
xMethod(new double[5]);
xMethod(new double[3]{1, 2,
3}); } public static void xMethod(double[] a) {
System.out.println(a.length); }}
52) ______
A) The program has a syntax error because xMethod(new double[3]{1,
2, 3}) is incorrect.
B) The program has a runtime error because a is null.
C) The program has a syntax error because xMethod(new double[5])
is incorrect.
D) The program has a syntax error because xMethod(new double[]{3,
3}) is incorrect.
53) In the following code, what is the printout for list1?class Test { public
static void main(String[] args) {
int[] list1 = {1, 2, 3};
int[] list2 = {1, 2, 3};
list2 = list1;
list1[0] = 0;
list1[1] = 1; list2[2] = 2;
for (int i = 0; i < list1.length; i++)
System.out.print(list1[i] + " ");
}}
A) 0 1 2
B) 1 1 1
C) 1 2 3
54) The array index is not limited to int type.
53) ______
D) 0 1 3
54) ______
A) true
B) false
55) What would be the result of attempting to compile and run the
following code?
public class Test {
public static
void main(String[] args) {
double[] x = new double[]{1, 2,
3};
System.out.println("Value is " + x[1]);
}}
55) ______
A) The program has a syntax error because the syntax new double[]{1,
2, 3} is wrong and it should be replaced by new double[3]{1, 2, 3};
B) The program has a syntax error because the syntax new double[]{1,
2, 3} is wrong and it should be replaced by new double[]{1.0, 2.0,
3.0};
C) The program compiles and runs fine and the output "Value is 2.0"
is printed.
D) The program has a syntax error because the syntax new double[]{1,
2, 3} is wrong and it should be replaced by {1, 2, 3}.
E) The program compiles and runs fine and the output "Value is 1.0"
is printed.
56) Which of the following declarations are correct? (choose all that apply)
A) public static void print(double... numbers)
B) public static double... print(double d1, double d2)
C) public static void print(String... strings, double... numbers)
D) public static void print(int n, double... numbers)
E) public static void print(double... numbers, String name)
56) ______
57) When you return an array from a method, the method returns ________.
A) the reference of the array
B) a copy of the first element
C) the length of the array
D) a copy of the array
57) ______
58) The size of ________ can grow and shrink at runtime.
A) an ArrayList
B) an array
58) ______
59) Normally you depend on the JVM to perform garbage collection
automatically. However, you can explicitly use ________ to request
garbage collection.
A) System.gc(0)
B) System.gc()
C) System.exit()
D) System.exit(0)
59) ______
60) Analyze the following code.// Program 1:public class Test {
public
static void main(String[] args) {
Object a1 = new A();
Object a2 = new A();
System.out.println(a1.equals(a2));
}}class A {
int x; public boolean equals(A a) {
return
this.x == a.x;
}}// Program 2:public class Test {
public static
void main(String[] args) {
A a1 = new A();
A a2 =
new A();
System.out.println(a1.equals(a2));
}}class A {
int x; public boolean equals(A a) {
return this.x == a.x;
}}
A) Program 1 displays false and Program 2 displays true
B) Program 1 displays false and Program 2 displays false
C) Program 1 displays true and Program 2 displays false
D) Program 1 displays true and Program 2 displays true
60) ______
61) Given the following code, find the syntax error?public class Test {
public static void main(String[] args) {
m(new
GraduateStudent());
m(new Student());
m(new
Person());
m(new Object());
}
public static
void m(Student x) {
System.out.println(x.toString()); }}class
GraduateStudent extends Student {}class Student extends Person {
public String toString() {
return "Student";
}}class
Person extends Object { public String toString() {
return
"Person";
}}
61) ______
(choose all that apply)
A) m(new Object()) causes an error
B) m(new Student()) causes an error
C) m(new GraduateStudent()) causes an error
D) m(new Person()) causes an error
62) Analyze the following code:public class Test { public static void
main(String[] args) {
Object a1 = new A();
Object
a2 = new Object();
System.out.println(a1);
System.out.println(a2);
}}class A {
int x; public String
toString() {
return "A's x is " + x;
}}
62) ______
(choose all that apply)
A) When executing System.out.println(a2), the toString() method in
the Object class is invoked.
B) The program cannot be compiled, because System.out.println(a1)
is wrong and it should be replaced by
System.out.println(a1.toString());
C) When executing System.out.println(a1), the toString() method in
the Object class is invoked.
D) When executing System.out.println(a1), the toString() method in
the A class is invoked.
63) If a parameter is of the java.lang.Object type, you can pass any object to
it. This is known as generic programming.
A) true
B) false
63) ______
64) Which of the following statements are true? (choose all that apply)
A) It is a compilation error if two methods differ only in return type.
B) A private method cannot be overridden. If a method defined in a
subclass is private in its superclass, the two methods are
completely unrelated.
C) To override a method, the method must be defined in the subclass
using the same signature and return type as in its superclass.
D) Overloading a method is to provide more than one method with
the same name but with different signatures to distinguish them.
E) A static method cannot be overridden. If a static method defined in
the superclass is redefined in a subclass, the method defined in the
superclass is hidden.
64) ______
65) The UML uses ________ before a member name to indicate that the
me mber is
private.
65)
___
___
A) +
C) #
B) D) None of the above.
66) The getValue() method is overridden in two ways. Which one is
correct?I:public class Test {
public static void main(String[] args) {
A a = new A();
System.out.println(a.getValue());
}}class B {
public String getValue() {
return "Any
object"; }}class A extends B {
public Object getValue() {
return "A string";
}}II:public class Test { public static void
main(String[] args) {
A a = new A();
System.out.println(a.getValue());
}}class B {
public Object
getValue() {
return "Any object";
}}class A extends B {
public String getValue() {
return "A string";
}}
A) I
C) Neither
66) ______
B) II
D) Both I and II
67) Which of the following statements are true? (choose all that apply)
A) A subclass is a subset of a superclass.
B) "class A extends B" means B is a subclass of A.
C) A subclass is usually extended to contain more functions and more
detailed information than its superclass.
D) "class A extends B" means A is a subclass of B.
67) ______
68) Which of the following loops produces the following output? (choose all
that apply)1 2 3 4 1 2 3 1 2 1(I) for (int i = 5; i > 0; i--) {
for (int
j = 1; j < i; j++)
System.out.print(j + " ");
System.out.println(); }(II)
for (int i = 1; i < 5; i++) {
for (int
j = 1; j < i; j++)
System.out.print(j + " ");
System.out.println();
} (III)
int i = 0;while (i < 5) {
for (int j = 1; j < i; j++)
System.out.print(j + " ");
System.out.println();
i++;
}(IV)
int i = 5;while (i > 0) {
for (int j = 1; j < i; j++)
System.out.print(j + "
"); System.out.println();
i--;
}
68) ______
A) (I)
B) (II)
C) (IV)
D) (III)
69) How many times will the following code print "Welcome to Java"?int
count = 0;do { System.out.println("Welcome to Java");} while (++count
< 10);
A) 0
B) 8
C) 9
D) 10
69) ______
E) 11
70) You can always convert a for loop to a while loop.
A) true
B) false
70) ______
71) Analyze the following code.
int x = 1;
100)
System.out.println(x++);
71) ______
while (0 < x) && (x <
A) The code does not compile because (0 < x) && (x < 100) is not
enclosed in a pair of parentheses.
B)
C)
D)
E)
The numbers 1 to 99 are displayed.
The loop runs for ever.
The numbers 2 to 100 are displayed.
The code does not compile because the loop body is not in the
braces.
72) In a for statement, if the continuation condition is blank, the condition is
assumed to be ________.
A) true
B) false
72) ______
73) The while loop and the do loop are equivalent in their expressive
power; in other words, you can rewrite a while loop using a do loop,
and vice versa.
A) true
B) false
73) ______
74) Suppose cond1 is a Boolean expression. When will this while condition
be true?while (cond1) ...
74) ______
A) always false
C) in case cond1 is true
B) in case cond1 is false
D) always true
75) A break statement can be used only in a loop.
A) true
B) false
75) ______
76) The client can use a method without knowing how it is implemented.
The details of the implementation are encapsulated in the method and
hidden from the client who invokes the method. This is known as
________. (choose all that apply)
A) method hiding
B) encapsulation
C) simplifying method
D) information hiding
76) ______
77) Which of the following is not an advantage of using methods?
A) Using methods makes programs easier to read.
B) Using methods makes reusing code easier.
C) Using methods hides detailed implementation from the clients.
D) Using methods makes programs run faster.
77) ______
78) Variables defined in the method header are called ________.
A) parameters
B) arguments
C) local variables
D) global variables
78) ______
79) When you invoke a method with a parameter, the value of the argument
is passed to the parameter. This is referred to as ________.
A) method invocation
B) pass by value
C) pass by reference
D) pass by name
79) ______
80) Math.sqrt(4) returns ________.
A) 1
B) 2
80) ______
C) 1.0
D) 2.0
81) Which of the following is a possible output from invoking
Math.random()? (choose all that apply)
A) 1.0
B) 3.43
C) 0.5
D) 0.0
81) ______
82) Analyze the following code.int[] list = new int[5];list = new int[6];
A) The code has syntax errors because the variable list cannot be
changed once it is assigned.
B) The code can compile and run fine. The second line assigns a new
array to list.
C) The code has syntax errors because you cannot assign a different
size array to list.
D) The code has runtime errors because the variable list cannot be
changed once it is assigned.
82) ______
83) Suppose a method p has the following heading:public static int[][]
p()What return statement may be used in p()?
A) return new int[]{1, 2, 3};
B) return 1;
C) return {1, 2, 3};
D) return new int[][]{{1, 2, 3}, {2, 4, 5}};
E) return int[]{1, 2, 3};
83) ______
84) Analyze the following code:
int[][] matrix = new int[5][5];
column = 0; column < matrix[4].length; column++)
matrix[4][column] = 10;
A) After the loop, the last row of matrix 10, 10, 10, 10, 10.
B) After the loop, the last column of matrix 10, 10, 10, 10, 10.
C) After the loop, the last row of matrix 0, 0, 0, 0, 10.
D) After the loop, the last row of matrix 0, 0, 0, 0, 0.
for (int
84) ______
85) In the following code, what is the printout for list2?class Test { public
static void main(String[] args) {
int[] list1 = {3, 2, 1};
int[] list2 = {1, 2, 3};
list2 = list1;
list1[0] = 0;
list1[1] = 1; list2[2] = 2;
for (int i = list2.length - 1; i >= 0; i--)
System.out.print(list2[i] + " ");
}}
A) 0 1 3.
B) 3 2 1
C) 1 2 3
D) 0 1 2
E) 2 1 0
85) ______
86) Which of the statements regarding the super keyword is incorrect?
A) You cannot invoke a method in superclass's parent class.
B) You can use super to invoke a super class method.
C) You can use super.super.p to invoke a method in superclass's
parent class.
D) You can use super to invoke a super class constructor.
86) ______
87) Suppose ArrayList x contains two strings [Beijing, Singapore]. Which of
the following method will cause the list to become [Beijing, Chicago,
Singapore]?
A) x.add(2, "Chicago")
B) x.add(0, "Chicago")
C) x.add("Chicago")
D) x.add(1, "Chicago")
87) ______
88) You can use the operator == to check whether two variables refer to the
same object, and use the equals() method to check the equality of
contents of the two objects.
A) true
B) false
88) ______
89) What is the value of balance after the following code is executed?int
balance = 10;while (balance >= 1) {
if (balance < 9) break;
balance = balance - 9;}
A) 1
B) -1
C) 0
D) 2
90) What is i after the following for loop?int y = 0;for (int i = 0; i<10; ++i) {
y += i; }
A) 10
C) 11
89) ______
90) ______
B) undefined
D) 9
91) Which of the following expression yields an integer between 0 and 100,
inclusive?
A) (int)(Math.random() * 100)
B) (int)(Math.random() * 100 + 1)
C) (int)(Math.random() * 101)
D) (int)(Math.random() * 100) + 1
91) ______
92) The actual parameters of a method must match the formal parameters in
type, order, and number.
A) true
B) false
92) ______
93) The signature of a method consists of the method name, parameter list
and return type
A) true
B) false
93) ______
94) Suppose a method p has the following heading:public static int[]
p()What return statement may be used in p()?
A) return int[]{1, 2, 3};
B) return new int[]{1, 2, 3};
C) return 1;
D) return {1, 2, 3};
94) ______
95) Which of the following are Java keywords?
A) instanceOf
B) casting
C) cast
D) instanceof
95) ______
96) What is the number of iterations in the following loop:
n; i++) {
// iteration
}
A) 2*n
B) n + 1
C) n
for (int i = 1; i <
96) ______
D) n - 1
97) The modifiers and return value type do not contribute toward
distinguishing one method from another, only the parameter list.
A) true
B) false
97) ______
98) Suppose int[] numbers = new int[10], what is numbers[0]?
A) undefined
B) 0
C) 10
D) null
98) ______
99) ________ can search in an unsorted list.
A) Binary search
B) Linear search
99) ______
100) What the output of the following code:for ( ; ; )
System.out.println("Welcome to Java");
100)
_____
A)
B)
C)
D)
prints out Welcome to Java two times.
prints out Welcome to Java one time.
prints out Welcome to Java forever.
does not print anything.
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
11)
12)
13)
14)
15)
16)
17)
18)
19)
20)
21)
22)
23)
24)
25)
26)
27)
28)
29)
30)
31)
32)
33)
34)
35)
36)
37)
38)
39)
40)
41)
42)
43)
44)
45)
46)
47)
48)
49)
50)
51)
A
A
A
C
A, D
A
C
A
B
D
D
B
C
E
A
C
C
B
B
A
E
E
D
A
B
C
B
A, B
D
C
B
D
A, D
B
C
B
B
D
B
D
A
A
C
C
B
D
A
D
C
A
B
52) A
53) A
54) B
55) C
56) A, D
57) A
58) A
59) B
60) A
61) A, D
62) A, D
63) A
64) A, B, C, D, E
65) B
66) B
67) C, D
68) A, C
69) D
70) A
71) A
72) A
73) A
74) B
75) B
76) B, D
77) D
78) A
79) B
80) D
81) C, D
82) B
83) D
84) A
85) E
86) C
87) D
88) A
89) A
90) B
91) C
92) A
93) B
94) B
95) D
96) D
97) A
98) B
99) B
100) C
Download