Exam Permalink:
https://www.jobilize.com/java-certification-questions
Question Permalink:
https://www.jobilize.com/how-to-use-java-instanceof
Question 43 / 297:  Which lines will evaluate to true?
interface Colorable { }

interface Bouncable extends Colorable { }

class Super implements Bouncable { }

class Sub extends Super implements Bouncable { }

public class Tester {

public static void main(String[] args) {

System.out.println(new Sub() instanceof Super); //line 1

System.out.println(new Sub() instanceof Bouncable);//line 2

System.out.println(new Sub() instanceof Colorable);//line 3

System.out.println(new Super() instanceof Sub);//line 4

System.out.println(new Super() instanceof Colorable);//line 5

}

}

Oracle Certified Professional Java Programmer Yasser Ibrahim How to use java instanceof?
A  All lines will evaluate to true
B  All lines will evaluate to true and only line 4 will evaluate to false
C  Only line 1 and 2 will evaluate to true
D  Lines 3 and 5 will evaluate to false
<< First < Previous Next > Last >>
Explanation:

Since Bouncable extends Colorable then both Super and Sub implicitly implementing Colorable

Exam Home Page
https://www.jobilize.com/java-certification-questions

Oracle Certified Professional Java Programmer

Author:

Access: Public Instant Grading

Ask
Saylor Foundation
Start Quiz
Robert Murphy
Start Test
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>