Question 119 / 297:  What inserted, independently at // insert code here , will compile and run with no errors and exceptions?
Choose 2
class Creature {

void grow() {

}

}

class Bird extends Creature {

void fly() {

}

}

class Falcon extends Bird {

void hunt() {

}

}

public class Tester {

public static void main(String[] args) {

Creature c1 = new Bird();

Falcon c2 = new Falcon();

// insert code here

}

}

Oracle Certified Professional Java Programmer JavaChamp Team How to java cast?
<< First < Previous Next > Last >>
Explanation:

c1.fly() causes a compilation error.

((Falcon)c1).hunt() compiles fine but throws a ClassCastException at runtime.

Exam Home Page
Ask
Yacoub Jayoghli
Start Quiz
Stephanie Redfern
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>