Java OCA OCP Practice Question 1302

Question

Fill in the blanks:

A class may be assigned to a(n) ___ reference variable automatically but requires an explicit cast when assigned to a(n) reference variable.

  • A. subclass, outer class
  • B. superclass, subclass
  • C. subclass, superclass
  • D. abstract class, concrete class


B.

Note

A class can trivially be assigned to a superclass reference variable but requires an explicit cast to be assigned to a subclass reference variable.

Option B is correct.




PreviousNext

Related