The answer will be 4
a
1 is incorrect(explanation --> 4) 2 is incorrect syntax 3 is incorrect typecast.
Note that answer 3 is valid as long as it is roughly compilation . When you say that you have an instance of the Phone class, you can type cast in Tablet (Just like you can use Object for String ). And since Tablet implements Roamable , you can very well use the Roamable link to link it. Problem will occur at runtime , because Object really is of type Phone .
This is only one of the binders (in the current context) that allows you to successfully compile. But as God said in his answer in general
If we attribute the reference S (non final) to compile time to compile the time job T, then compilation will succeed as even if S does not implement T, a subclass of S might . If S is a finite class, then S must implement T, or a compile-time error occurs.
Actually there is no need for a Tablet class extending the Phone class. While the phone class not final compilation will succeed
interface Roamable{} class Phone {} class Tablet implements Roamable { Roamable var = (Roamable)new Phone();
source share