Question 44 / 297:  what is the result of compiling and running the following code?
interface Colorable { }

interface Bouncable extends Colorable { }

class Super implements Bouncable { }

class Sub extends Super implements Bouncable { }

class Individual { }

public class Tester {

public static void main(String[] args) {

System.out.print(new Sub() instanceof Super);

System.out.print(new Sub() instanceof Colorable);

System.out.print(new Super() instanceof Sub);

System.out.print(new Individual() instanceof Super);

}

}

A  truetruefalsefalse
B  truefalsefalsefalse
C  Compilation error
D  RuntimeException becaue of the print statemen
<< First < Previous Next > Last >>
Explanation:

Individual and Super are incompatible, so using instanceof causes a compilation error.

Operands of instanceof must be in the same inheritance tree.

Exam Home Page
Ask
Mike Wolf
Start Exam
Nicole Bartels
Start Quiz
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>