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();

  1. (20 pts) What is the output of this code sequence?

B b3 = new B();

int n = b3.foo2();

  1. (20 pts) What is the output of the following code?

//b4 is a B object reference

System.out.println(b4.foo3());

  1. (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.

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

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

Evaluate the impact of unions on nurses and physicians.

Answered: 1 week ago

Question

Describe the impact of strikes on patient care.

Answered: 1 week ago

Question

Evaluate long-term care insurance.

Answered: 1 week ago