Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following class definitions: public class A { private int number; p

ID: 3535944 • Letter: C

Question

Consider the following class definitions:

public class A

{

private int number;

private String text;

public A(int n, String txt)

{

number = n;

text = txt;

}

public A(A obj)

{

number = obj.number;

text = obj.text;

}

public String toString()

{

return "The object value: " + number + " and " + text;

}

}



public class B extends A

{

private int number;

public B(int localN, int parentNum, String parentTxt)

{

//What goes here?

number = localN;

}

public String toString()

{

return "The child has the value: " + number + " and the parent has the value: " + //What goes here

}

}



Two questions:

1. The constructor for class B is incomplete because the call for the parent object is missing. Write that call in the first blank space.

2. The child wants to output its content and the parent object's content. Write only the part that calls the parent's output method in the second blank space.

Explanation / Answer

1) super( parentNum, ParentTxt);


2) super.toString();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote