Java OCA OCP Practice Question 1552

Question

Consider the following classes...

class MyBaseClass{
      void print (String student){
          /* lots of code */
       }
}
class Prof extends MyBaseClass{
        //1
}

Which of the following methods can be inserted at line // 1 ?

Select 4 options

  • A. public void print () throws Exception
  • B. private void print (int i) throws Exception
  • C. protected void print (String s)
  • D. public final void print (String s)
  • E. public abstract void print (String s)


Correct Options are  : A B C D

Note

'protected' is less restrictive than default 'no modifier'.

So choice 3 is valid.

"public abstract void print(String s)" would have been valid if class Prof had been declared abstract.




PreviousNext

Related