Java OCA OCP Practice Question 2655

Question

Which of the following statements can be inserted in the blank line so that the code will compile successfully? (Choose all that apply.)

public interface Printable {} 
public class Shape implements Printable { 
   public static void main(String[] args) { 
      _______________ frog = new Circle(); 
   } 
} 
public class Square extends Shape {} 
public class Circle extends Shape {} 
  • A. Shape
  • B. Circle
  • C. Square
  • D. Printable
  • E. Object
  • F. Long


A, B, D, E.

Note

The blank can be filled with any class or interface that is a super type of TurtleShape.

A is a superclass of Circle, and B is the same class, so both are correct.

Square is not a superclass of Circle, so C is incorrect.

Circle inherits the Printable interface, so D is correct.

All classes inherit Object, so E is correct.

Finally, Long is an unrelated class that is not a superclass of Circle, and it is therefore incorrect.




PreviousNext

Related