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

For the questions below, consider the following class definition: public class A

ID: 3779086 • Letter: F

Question

For the questions below, consider the following class definition: public class AClass { protected int x; protected int y; public AClass(int a, int b) { x = a; y = b; } public int addEm( ) { return x + y; } public void changeEm( ) { x++; y--; } public String toString( ) { return "" + x + " " + y; } } Consider that you want to extend AClass to BClass. BClass will have a third int instance data, z. Which of the following would best define BClass'constructor? 1. public BClass(int a, int b, int c) { super( ); } 2. public BClass(int a, int b, int c) { z = c; } 3. public BClass(int a, int b, int c) { super(a, b, c); } 4. public BClass(int a, int b, int c) { super(a, b); z = c; } 5. public BClass(int a, int b, int c) { x = a; y = b; z = c; }

Explanation / Answer

The best definition of B Class'constructor is

public BClass(int a, int b, int c) {

super(a, b);

z = c;

}

So the answer is option (4)

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