Suppose that the following variables referring to the classes from the previous problem are declared: Pond var1

Question:

Suppose that the following variables referring to the classes from the previous problem are declared:

Pond var1 = new Bay();

Object var2 = new Ocean();

Which of the following statements produce compiler errors? For the statements that do not produce errors, what is the output of each statement?

((Lake) var1).method1();

((Bay) var1).method1();

((Pond) var2).method2();

((Lake) var2).method2();

((Ocean) var2).method3();


Data from Previous Problem

Assume that the following classes have been defined:

1 public class Bay extends Lake { public void method1 () { 3 System.out.print (

What output is produced by the following code fragment?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: