Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following classes: Suppose the following variables are defined: Ind

ID: 3566068 • 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.method1(); var2.method1(); var3.method1(); var4.method1(); var5.method1(); var6.method1(); var1.method2(); var2.method2(); var3.method2(); var4.method2(); var5.method2(); var6.method2(); var3.method3(); var5.method3(); ((Larry) var1).method1(); ((Mary) var2).method2(); ((Jerry) var5).method1(); ((Mary) var5).method3(); ((Jerry) var4).method3(); ((Mary) var6).method3();

Explanation / Answer

var1.method1();   ---> harry 1
var2.method1();   --> larry 1/harry1
var3.method1();   --> larry 1/harry1
var4.method1();   --> larry 1/harry1
var5.method1();   --> larry 1/harry1
var6.method1();   -->The method method1() is undefined for the type Object
var1.method2();   -->harry 1/harry 2
var2.method2();   -->larry 1/harry 1/harry 2
var3.method2();   -->mary 2/jerry 2
var4.method2();   -->mary 2
var5.method2();   -->mary 2/jerry 2
var6.method2();   --->Error//The method method2() is undefined for the type Object
var3.method3();   --->Error//The method method3() is undefined for the type Larry
var5.method3();   -->larry 1/harry 1/mary 3
((Larry) var1).method1();   ---->Exception//p1.Harry cannot be cast to p1.Larry
((Mary) var2).method2();   --->Exception//p1.Larry cannot be cast to p1.Mary
((Jerry) var5).method1();   -->larry 1/harry 1
((Mary) var5).method3();   -->larry 1/harry 1/mary 3
((Jerry) var4).method3();   -->Exception// p1.Mary cannot be cast to p1.Jerry
((Mary) var6).method3(); -->Exception//p1.Larry cannot be cast to p1.Mary

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote