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:
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
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Question Posted: