Question: 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

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.

please explain each answer. Answer why this output is given. someone answered it before but did not explain the answers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!