Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

=+j Understand different types of regions in the world.

Answered: 1 week ago