Java OCA OCP Practice Question 2605

Question

Given:

1. interface Printable {   
2.   void print();   
3. }  /*from w  w w .  j a  va 2 s.co m*/
4. abstract class Shape implements Printable { }  
5.  
6. class Rectangle implements Shape {  
7.   public void print() { ; }   
8. }  
9. class Square extends Rectangle {   
10.   void print(int s) { ; }  
11. } 

    

Which are true? (Choose all that apply.).

  • A. Compilation succeeds.
  • B. Compilation fails due to an error on line 2.
  • C. Compilation fails due to an error on line 4.
  • D. Compilation fails due to an error on line 6.
  • E. Compilation fails due to an error on line 7.
  • F. Compilation fails due to an error on line 9.
  • G. Compilation fails due to an error on line 10.


D is correct.

Note

Classes extend abstract classes, they don't implement them.

The method on line 10 doesn't need to be declared public because it's an overload of the parent method, not an override.




PreviousNext

Related