MCQs > IT & Programming > Java > Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program? class A {} class B extends A {} class C extends A {} public class X { public static void main(String args[]) { A x = new A(); B y = new B(); C z = new C(); // insert statement here } }

Java MCQs

Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program?

 class A {}
 class B extends A {}
 class C extends A {}
 public class X {
 public static void main(String args[]) {
 A x = new A();
 B y = new B();
 C z = new C();
 // insert statement here
 }
 }

Answer

Correct Answer: y = (B)x;

Explanation:

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it