Question

In: Computer Science

create an interface called Visible that has two methods called makeVisiible, makeInvisible. both methods take no...

create an interface called Visible that

  • has two methods called
    • makeVisiible,
    • makeInvisible.
  • both methods take no parameters and should return a boolean result.

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"

Solutions

Expert Solution

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 {
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 ");
}
}

//Creating new class "Jack"
class Jack extends Leo{

@Override
public void method1() {
System.out.print("Jack 1 ");
super.method1();
}

@Override
public void method2() {
super.method2();
System.out.print("Jack 2 ");
}
  
@Override
public void method3() {
System.out.print("Jack 3 ");
super.method3();
super.method2();
}   
  
@Override
public String toString() {
return "Jack 3 " + super.toString();
}
  
}

######################################################################

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 :)


Related Solutions

Define an interface called Shape that requires methods to get x and y, and a method...
Define an interface called Shape that requires methods to get x and y, and a method to calculate the area. Call these methods getX(), getY(), and getArea(). Write a class called MyRectangle that implements the Shape interface and contains: the double data fields x, y , and width with get and set methods a no-arg constructor that creates a default rectangle with 0 for both x and y and 1 for both length and width a constructor that creates a...
Programming Language : JAVA Create an interface named Turner, with a single method called turn(). Then...
Programming Language : JAVA Create an interface named Turner, with a single method called turn(). Then create 4 classes: 1- Leaf: that implements turn(), which changes the color of the Leaf object and returns true. If for any reason it is unable to change color, it should return false (you can come up with a reason for failure). The new color can be determined at random. 2- Document: that implements turn(), which changes the page on the document to the...
In Java Create an interface Create an interface Printing, which have a method getPageNumber () that...
In Java Create an interface Create an interface Printing, which have a method getPageNumber () that return page number of any printing. Create an abstract class named Novel that implements Printing. Include a String field for the novel's title and a double field for the novel price. Within the class, include a constructor that requires the novel title, and add two get methods--one that returns the title and one that returns the price. Include an abstract method named setPrice().. Create...
The directions say to "create two methods:
The directions say to "create two methods: -enrollStudent (Student newStudent) which adds newStudent into the enrolled list and increment numOfEnroll by 1, if the section is full, print out an error message and no change with numOfEnroll. -removeStudent (String studentId) which removes the student with studentId from the enrolled list and decrement numOfEnrollby 1, if the target student is not found in the enrolled list, print out an error message and no change with numOfEnroll."  
using python 1. #Write a function called multiply_file_by_index. This function #should take two parameters, both strings....
using python 1. #Write a function called multiply_file_by_index. This function #should take two parameters, both strings. The first string is #the filename of a file to which to write (output_file), and #the second string is the filename of a file from which to read #(input_file). # #In the input file, there will be an integer on every line. #To the output file, you should write the integer from the #original file multiplied by the line number on which it #appeared....
Create a web interface that has a backend database that takes a value of one table...
Create a web interface that has a backend database that takes a value of one table and displays it match from another table. Create a web interface, that has a backend database, the database contains two tables, one table contains courses in one curriculum, while the other table in the database has corresponding classes from another curriculum. A user should be able to pick a course from the curriculum, and the matching course from the other table should populate on...
Write a JAVA program called Convertor that has two methods. The first one converts an input...
Write a JAVA program called Convertor that has two methods. The first one converts an input binary into its equivalent decimal number. The second method converts a decimal number into its equivalent binary.​ binary2Decimal, decimal2Binary are the names for those methods.​ binary2Decimal receives a binary number as a string and returns a decimal number as an integer. And vice versa for the decimal2Binary method.​
There are two common methods used for analyzing a truss. Briefly discuss both methods with the...
There are two common methods used for analyzing a truss. Briefly discuss both methods with the aid of diagrams.
Create an interface MessageEncoder that has a single abstract method encode(plainText) where the plainText is the...
Create an interface MessageEncoder that has a single abstract method encode(plainText) where the plainText is the message to be encoded. The method will return the encoded version of the message. Then create a class SubstitutionCipher that implements this interface. The constructor should have on parameter called shift. Define the method encode so that each letter is shifted by the value in shift. For example if shift is 3 a will be replaced by d, b will be replaced by e....
JAVA Add static methods largest and smallest to the Measurable interface. The methods should return the...
JAVA Add static methods largest and smallest to the Measurable interface. The methods should return the object with the largest or smallest measure from an array of Measurable objects.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT