Consider the following classes: Suppose the following variables are defined: Ind
ID: 3566071 • Letter: C
Question
Consider the following classes:
Suppose the following variables are defined:
Indicate on each line below the output produced by each statement shown. If the statement produces more than one line of output indicate the line breaks with slashes as in a/b/c to indicate three lines of output with a followed by b followed by c. If the statement causes an error, write the word error to indicate this.
var1.method2(); var2.method2(); var3.method2(); var4.method2(); var5.method2(); var6.method2(); var1.method3(); var2.method3(); var3.method3(); var4.method3(); var5.method3(); var6.method3(); ((Sip) var6).method1(); ((Gulp) var1).method1(); ((Gulp) var1).method2(); ((Bite) var1).method3(); ((Bite) var6).method1(); ((Drink) var1).method1(); ((Drink) var4).method2(); ((Bite) var3).method1();Explanation / Answer
var1.method2(); The method method2() is undefined for the type Object var2.method2(); Gulp 2 var3.method2(); Exception in thread "main" java.lang.ClassCastException: Drink cannot be cast to Sip at ext.main(ext.java:31) var4.method2(); Gulp 3 var5.method2(); The method method2() is undefined for the type Object var6.method2(); Gulp 2 var1.method3(); The method method3() is undefined for the type Object var2.method3(); Sip 3 var3.method3(); Gulp 2 var4.method3(); Drink 3 var5.method3(); The method method3() is undefined for the type Object var6.method3(); Gulp 3 ((Sip) var6).method1(); Sip 3 ((Gulp) var1).method1(); The method method1() is undefined for the type ext.Gulp ((Gulp) var1).method2(); Drink 3 ((Bite) var1).method3(); Drink 3 ((Bite) var6).method1(); Bite 1 ((Drink) var1).method1(); Exception in thread "main" java.lang.ClassCastException: Bite cannot be cast to Drink at ext.main(ext.java:40) ((Drink) var4).method2(); Gulp 2 ((Bite) var3).method1();Drink 3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.