Java OCA OCP Practice Question 2782

Question

Given:

2. abstract class Tool {  
3.   int Count;  
4.   abstract void getCount();  
5. }  
6. public class Hammer {  
7.   // insert code here  
8. } 

Which line(s), inserted independently at line 7, will compile? (Choose all that apply.)

  • A. void getCount() { ; }
  • B. private void getCount() { ; }
  • C. protected void getCount() { ; }
  • D. public void getCount() { ; }


A, B, C, and D are ALL correct.

Note

It's a trick question-you might get something like this on the real exam.

It's easy if you notice that on line 6 the code does NOT say "extends Tool".

If line 6 did say "extends Tool", the correct answer would be A, C, and D.

There are no incorrect answers.




PreviousNext

Related