Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(A() called);

For Questions 1-3: consider the following code: 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); } protected int foo2() { Sysem.out.println(A version of foo2() called); return number; } public String foo3() { System.out.println(A version of foo3() called); Return Hi; } }//end class A public class B extends A { private char service; public B() { super(); System.out.println(B() called); } public void foo1() { System.out.println(B version of foo1() 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()); return (temp+ foo3); } }//end class B public class C extends B { public C() { super(); System.out.println(); } public void foo1() { System.out.println(C version of foo1() called); } }//end class C Assignment 1. (20 pts) What is the output of this code sequence? B b1 = new B(); 2. (20 pts) What is the output of this code sequence? B b3 = new B(); int n = b3.foo2(); 3. (20 pts) What is the output of the following code? //b4 is a B object reference System.out.println(b4.foo3()); 4. (40 pts) You coded the following class: public class N extends String, Integer { } When you compile, you get the following message: N.java:1: { expected public class N extends String, Integer ^ 1 error Explain what the problem is and how to fix it. ree program.

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

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions