Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started