In: Computer Science
create an interface called Visible that
HTML EditorKeyboard Shortcuts
12pt
Paragraph
0 words
Flag this Question
Question 58 pts
The following classes have been created with the given behaviors:
public class Leo extends Don { public void method1() { System.out.print("Leo 1 "); } public void method3() { System.out.print("Leo 3 "); } public String toString() { return "Leo 1 "; } } class Mike extends Leo { public void method2() { System.out.print("Mike 2 "); } } class Raph { public void method1() { System.out.print("Raph 1 "); } } class Don extends Raph { public void method2() { System.out.print("Don 2 "); } }
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.
method | 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" |
Here is the answer for your question in Java Programming Language.
Kindly upvote if you find the answer helpful.
NOTE : The interface question needs to be more clear i.e., what are the functionalities you expect the two methods in interface to do. Why you mentioned HTML Keyboard Shortcuts? Anything to do with shortcut keys? to answer it. Sincere apologies as I couldn't help you with this.
I could help you with creating class "Jack" that extends "Leo". Added the class after the class 'Don' in Leo.java file. Please comment below if you have any doubts.
############################################################################
CODE :
Leo.java
public class Leo extends Don { class Mike extends Leo { class Raph { class Don extends Raph { //Creating new class "Jack" @Override |
######################################################################
JackTester.java (To test Jack class methods)
public class JackTester { public static void main(String[] args){ Jack obj = new Jack(); System.out.print("Method 1 : "); obj.method1(); System.out.println(); System.out.print("Method 2 : "); obj.method2(); System.out.println(); System.out.print("Method 3 : "); obj.method3(); System.out.println(); System.out.print("toString() : "); System.out.println(obj); } } |
######################################################################
SCREENSHOTS :
Please see the screenshots of the code below for the indentations of the code.
###############################################################################
JackTester.java
##########################################################################
OUTPUT :
Any doubts regarding this can be explained with pleasure :)