For Brilliant Answers Only

profileInsaneUnk
hw-week4-multichoice.docx

Week4 Multiple Choice Assignment. Total Score (5):

Student Name: Score _____________________

1 points for each question (5 total) . 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:

Answer:

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() { }

Answer:

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 int methodD() { return 9;}

E. public int methodE() { return 9.0;}

F. public int methodF() { return;}

G. public int methodG() { return null;}

answer:

4. Given the following method, which of the method calls return 2? (Choose all that apply)

public int howMany(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]);

Answer:

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.

Answer: