1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Reika [66]
3 years ago
14

Create a class called Jack that extends Leo. This class must have the following behaviors/methods. You must use the inheritance

to reuse the methods from the parent classes. Solution without using the inheritance will get zero points. re-writting the code that already exists will get zero credit. A call to the methods in the parent classes must be donemethod description
method1 display "Jack 1 Leo 1 "
method2 displays "Don 2 Jack 2"
method3 displays "Jack 3 Leo 3 Don 2 "
toString displays" Jack 3 Leo 1"
Computers and Technology
1 answer:
lara [203]3 years ago
8 0

Answer:

public class Leo{

public String method1(){

return "Jack 1 Leo 1";

}

public String method2(){

return "Don 2 Jack 2";

}

public String method3(){

return "Jack 3 Leo 3 Don 2";

}

public String toString(){

return "Jack 3 Leo 1"

}

}

public class Jack extends Leo{

}

Explanation:

Leo is the parent class and jack inherits all of its attributes from Leo

So when you call the following code in the main method:

Jack j = new Jack();

System.out.println(j.method1);

it should print Jack 1 Leo 1

This is because the program first checks if method 1 exists in the Jack class

Because it doesn't exist it then goes to the parent class which is Leo.

And in the Leo class method1 displays "Jack 1 Leo 1 "

So it prints that

You might be interested in
A coworker is taking a computer overseas and asks you what concerns he should have. What do you tell him
DerKrebs [107]

Answer:

The components within the computer can get damage during travel, so he could improve the box protection with foam thingies

Explanation:

3 0
2 years ago
Which is the correct process for selecting consecutive rows in a worksheet?
bekas [8.4K]
<span>Click the heading of the first row in the selection, hold down the Shift key, and click the heading of the last row in the selection</span>
5 0
3 years ago
The copy constructor for a class is called____________.
White raven [17]

Answer:

b.) when an object of the class is initialized by another object of the class

Explanation:

the copy constructor for a class is called <u>when an object of the class is initialized by another object of the class</u>

4 0
4 years ago
What is a mechanical gear and how does it work to create more power?
Neko [114]
Its a gear that is not turned manually and it can spin faster and longer than a manual gear.
5 0
3 years ago
Mechanisms that can be used to rescue accident victims
stiks02 [169]

Answer:

Hydraulic rescue tools

6 0
2 years ago
Other questions:
  • Give a big-O estimate for the number of comparisons used by the algorithm that determines the number of 1s in a bit string of le
    9·2 answers
  • Write a program that takes as input an arithmetic expression followed by a semicolon ";". The program outputs whether the expres
    11·1 answer
  • A data set has 60 observations with minimum value equal to 30 and a maximum value equal to 72. The estimated class width using t
    11·1 answer
  • Which line of code will print I can code on the screen?
    13·1 answer
  • Package hw1;
    10·1 answer
  • Which method of accessing FTP has the most limited capabilities?
    9·2 answers
  • How are additional slides added to presentations? select all that apply
    10·1 answer
  • Please help i will give you brainelst answer part B thank you!!!!!!!!!!!!!1
    13·1 answer
  • Amanda would like to add text to a slide in her presentation. Select all of the correct methods she can use to add text.
    6·1 answer
  • How goes design again ones attention?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!