Question: Consider the following class definition: public class AppleClass { private int x; private int y; public AppleClass(int a, int b) { x = a; y

Consider the following class definition: public class AppleClass { private int x; private int y; public AppleClass(int a, int b) { x = a; y = b; } public int addNum( ) { return x + y; } public void changeNum( ) { x++; y--; } public String toString( ) { return + x + + y; } } Suppose that you want to extend AppleClass to BanannaClass. BanannaClass will have a third int instance variable, z. Which of the following would best define BanannaClass constructor?

public BanannaClass(int a, int b, int c) { x = a; y = b; z = c; }
public BanannaClass(int a, int b, int c) { z = c; }
public BanannaClass(int a, int b, int c) { super(a, b); z = c; }
public BanannaClass(int a, int b, int c) { super( ); }
public BanannaClass(int a, int b, int c) { super(a, b, c); }

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!