Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is Java Programing Language Question 5: Inheritance Question (20 pointa): Given the following class hierarchy and the object declarations, write down the outputs produced

This is Java Programing Language
image text in transcribed
Question 5: Inheritance Question (20 pointa): Given the following class hierarchy and the object declarations, write down the outputs produced by the given method calls below - assuming that there is no ordering implied in the questions and each statement is an independent one: public class Harry { public void method1() { System.out.println("harry 1"); Suppose that the following variables are defined Harry vari new Harry(); Harry var2 - new Larry(): Larry vara new Jerry(): Mary vard new Mary(): Mary vars- new Jerry(): Object var6= new Larry); public void method2() { nethodi(); Systen.out.printin("harry 2"): Indicate on each line below the output produced by each statement shown. public class Larry extends Harry { public void nethodi() { Systen.out.printin("larry 1"); super.nethod1(): If the statement produces more than one line of output indicate the line breaks with slashes as in a/ble to indicate three lines of output with a followed by b followed by e. public class Mary extends Larry ( public void nethod2()( Systen.out.print in("mary 2" : If the statement causes an error, write the word error to indicate this. G public void me thod3() { super.method1(): Systen.out.print In("nary 3"); public class Jerry extends Mary { public void method2(){ super.method2(): Systen.out.printin("jerry 2"); onthe ion var1.method1()3; .01 02 var2.method1()3; var3. method1()3; .03 var4.method1()3; .04 var5.method1(); .05 vari.method2(); .06 var4. method2(); .07 Var5.method2()3; .08 ((Mary) var5).method3 (); .09 ((Jerry) var4)- method3(); .10 Page 3 of 5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions