Java OCA OCP Practice Question 240

Question

Suppose the declared type of x is a class, and the declared type of y is an interface.

When is the assignment x = y; legal?

  • A. When the type of x is Object
  • B. When the type of x is an array
  • C. Always
  • D. Never


A.

Note

An interface may be converted only to a class, and the class must be Object.




PreviousNext

Related