Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 Reading and Understanding Code Consider the following three classes: public class A private int number; protected String name; public double price; public A() {

image text in transcribedimage text in transcribedimage text in transcribed

3 Reading and Understanding Code Consider the following three classes: public class A private int number; protected String name; public double price; public A() { System.out.println( "A() called"); private void foo1() { System.out.println("A version of foo1 () called"); privers a todos operatin e "a ver pokemon get some sa version of 10020) carlos protected int foo2() { System.out.println("A version of foo2() called"); return number; public String foo3() { System.out.println( "A version of foo3() called"); return "Hi"; public class B extends A private char service; public B() { super ; public B { super(); System.out.println("B) called" ); public void foo1() { System.out.println("B version of fool() called"); protected int foo2() { int n = super.foo2(); System.out.println("B version of foo2() called"); return ( n + 5); public String foo3() { String temp = super.foo3(); System.out.println("B version of foo3() called"); return ( temp + " foo3"); } public class C extends B public c(){ super(); System.out.println("C() called"); public void foo1() { System.out.println("C version of fooi () called"); Answer the following questions without typing the code: 1. Draw a UML diagram for the class hierarchy. 2. what files and methods are inherited by which class? 3. What fields and methods are not inherited? 4. what is the output of the following code sequence? Bb1 = new B(); 5. What is the output of the following code sequence? Bb2 = new B(); b2.fool(); 6. What is the output of the following code sequence? B b3 = new B(); int n = b3.foo2(); 7. What is the output of the following code sequence? 1/64 is a B object reference System.out.println (b4.foo3()); 8. What is the output of the following code sequence? C cl = new C(); 9. What is the output of the following code sequence? // c2 is a c object reference c2.fool()

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions