Question 35 / 35:  Which lines will produce type cast exceptions ?
Choose 4
package ocjp;

class Creature {}

class Bird extends Creature {}

class Falcon extends Bird {}

public class Program6 {

public static void main(String[] args) {

Creature c1 = new Creature();

Creature c2 = new Bird();

Bird b1 = (Bird) c1; // Line 1

Bird b2 = (Falcon) c2; // Line 2

Bird b3 = (Bird)c2; // Line 3

Bird b4 = new Falcon(); // Line 4

Bird b5 = (Bird) new Creature(); // Line 5

Falcon f1 = b4; // Line 6

System.out.println("succuess");

}

}

<< First < Previous Next > Last >>
Quiz Home Page
https://www.jobilize.com/ocjp-1z0-803-oca1-7-mock-exam-quiz-by-pankaj-kalra

OCA(1z0-803_OCA1.7)MockExamPI

Author:

Access: Public Instant Grading

Ask
Dionne Mahaffey
Start Quiz
Madison Christian
Start Test
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/ocjp-1z0-803-oca1-7-mock-exam-quiz-by-pankaj-kalra" 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>