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

JAVA code Create a new class called BetterDiGraph that implements the EditableDiGraph interface See the interface...
JAVA code Create a new class called BetterDiGraph that implements the EditableDiGraph interface See the interface below for details. EditableDigraph below: import java.util.NoSuchElementException; /** * Implements an editable graph with sparse vertex support. * * */ public interface EditableDiGraph {    /** * Adds an edge between two vertices, v and w. If vertices do not exist, * adds them first. * * @param v source vertex * @param w destination vertex */ void addEdge(int v, int w); /** *...
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...
3. Which statement about methods in an interface is true? A.)All methods in an interface must...
3. Which statement about methods in an interface is true? A.)All methods in an interface must be explicitly declared as private or public. B.)All methods in an interface are automatically public. C.)All methods in an interface are automatically private. D.)All methods in an interface are automatically static.
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...
1. Create a symbolic constant called PI in two different manners. For both, the value that...
1. Create a symbolic constant called PI in two different manners. For both, the value that is associated with the constant should be 3.14159 2. x = 0; y = 5; Is the following condition true or false? if ( x > 0 and x < 10 or y = = 4) 3. What statement is used to bring in libraries at the top of your C program?
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...
Define an interface called Vehicle, which requires the following methods getName: returns a String getTopSpeed: returns...
Define an interface called Vehicle, which requires the following methods getName: returns a String getTopSpeed: returns an int getMaxPassengers: returns an int Note that the class Car implements this interface and is preloaded (in one of the following questions you will define this class) For example: Test Vehicle v = new Car("BMW", 280, 5); System.out.println(v.getName()); System.out.println(v.getTopSpeed()); System.out.println(v.getMaxPassengers()); Results : BMW 280 5 Test 2 : Vehicle v = new Car("Smart", 150, 2); System.out.println(v.getName()); System.out.println(v.getTopSpeed()); System.out.println(v.getMaxPassengers()); Results : Smart 150 2
Using Java, write code as follows: Create an interface called Items. It should define at least...
Using Java, write code as follows: Create an interface called Items. It should define at least the following methods: public void add( Object item ) - adds a single object to the collection. public Object get( int index ) - returns an item at a specific index. public int size() - returns the number of items stored in the collection. public void addAll( Object[] items ) - adds all of the elements in the array to the collection. Write a...
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....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT