Any partially correct answers for a question will not get the point regardless how many choices applicable.
Please clearly mark your choice in a separate line such as:
Answer: A, D
1. Which of the following can fill in the blank in this code to make it compile? (Choose all that apply)
public class Ant {
_____ void method() { }
}
A. default
B. final
C. private
D. Public
E. String
F. zzz:
2. Which of the following compile? (Choose all that apply)
A. final static void method4() { }
B. public final int void method() { }
C. private void int method() { }
D. static final void method3() { }
E. void final method() {}
F. void public method() { }
3. Which of the following methods compile? (Choose all that apply)
A. public void methodA() { return;}
B. public void methodB() { return null;}
C. public void methodD() {}
D. public intmethodD() { return 9;}
E. public intmethodE() { return 9.0;}
F. public intmethodF() { return;}
G. public intmethodG() { return null;}
4. Given the following method, which of the method calls return 2? (Choose all that apply)
publicinthowMany(boolean b, boolean... b2) {
return b2.length;
}
A. howMany();
B. howMany(true);
C. howMany(true, true);
D. howMany(true, true, true);
E. howMany(true, {true});
F. howMany(true, {true, true});
G. howMany(true, new boolean[2]);
5. What is the output of the following code?
1: class Mammal {
2: public Mammal(int age) {
3: System.out.print("Mammal");
4: }
5: }
6: public class Platypus extends Mammal {
7: public Platypus() {
8: System.out.print("Platypus");
9: }
10: public static void main(String[] args) {
11: new Mammal(5);
12: }
13: }
A. Platypus
B. Mammal
C. PlatypusMammal
D. MammalPlatypus
E. The code will not compile because of line 8.
F. The code will not compile because of line 11.