Question

Using the interface and class definitions below, write the headings of all of the methods which...

Using the interface and class definitions below, write the headings of all of the methods which still need to be defined in the class Class2.

https://hastebin.com/kopejolila.java

 public interface Interface1 { 
     public float method1(int i) ;
  }

  public interface Interface2 extends Interface1 {
     public int method2(int i) ; 
     public void method3(int i) ; 
  } 

  public abstract class Class1 {
     public float method1(int anInt) {
        return anInt * 2.0f ;
     } 
     public abstract void method3(Object anObject) ; 
     public abstract void method4(int anInt) ; 
  }

  public class Class2 extends Class1 implements Interface2 {  
     public void method3(int anInt) {
        System.out.println(anInt) ;
     }
       What other method headings need to be defined here?
  }

List the headings of methods that still must be defined in Class2 in the box below so that Class2 will compile.

Homework Answers

Answer #1

Answer.)

To Compile Class 2, the below methods needs to be overridden :

  • public int method2(int i)
  • public void method3(Object anObject)
  • public void method4(int anInt)

Explanation: As Class 2 extends Class 1, which already has the implementation of method1(), it is not required to override. However, method3(Object anObject) of Class 1 needs to be overridden as the method arguments are different as implemented in Class 2. Also, as Class 2 implements Interface 2 and extends Class 1, so abstract methods - method2(int I) of Interface 2 and method4(int anInt) of Class 1 needs to be implemented.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Question 6 (6 pts) The interface SayHello is defined as followed: public interface SayHello {             void...
Question 6 (6 pts) The interface SayHello is defined as followed: public interface SayHello {             void printGreeting( ); } Write the statements to instantiate an object of the anonymous class that implements the above interface by using the following definition of printGreeting(   ) and then call the instance method printGreeting( ). void  printGreeting(    ) {             System.out.println(“Hello guys”); } Question 7 (8 pts) The abstract class SayHello and the static method process are defined as followed: class SayHello {             private String greeting; SayHello(  ...
Write an interface Shape with methods getShapeName and getPerimeter. Write classes called Square, Rectangle, Circle and...
Write an interface Shape with methods getShapeName and getPerimeter. Write classes called Square, Rectangle, Circle and Triangle that implement the interface. Supply the proper parameters to the Square, Rectangle, Triangle and Circle constructors such that the perimeter can be calculated. Run THRou JDK compiler please Sample code: //Save this in Shape.java public interface Shape{ public double getPerimeter(); public String getShapeName(); } //Save this in Triangle.java public class Triangle implements Shape{ private double side1; private double side2; Triangle(double length1, double length2,...
3.2 Class Dictionary This class implements a dictionary using a hash table in which collisions are...
3.2 Class Dictionary This class implements a dictionary using a hash table in which collisions are resolved using separate chaining. The hash table will store objects of the class Data. You will decide on the size of the table, keeping in mind that the size of the table must be a prime number. A table of size between 5000-10000, should work well. You must design your hash function so that it produces few collisions. A bad hash function that induces...
Casting class objects 1.2 Compile and execute the code listed below as it is written. Run...
Casting class objects 1.2 Compile and execute the code listed below as it is written. Run it a second time after uncommenting the line obj.speak();. public class AnimalRunner {    public static void main(String[] args)    {       Dog d1 = new Dog("Fred");       d1.speak();       Object obj = new Dog("Connie");       // obj.speak();    } } The uncommented line causes a compile error because obj is an Object reference variable and class Object doesn’t contain a speak() method. This...
in jGRASP INVENTORY CLASS You need to create an Inventory class containing the private data fields,...
in jGRASP INVENTORY CLASS You need to create an Inventory class containing the private data fields, as well as the methods for the Inventory class (object). Be sure your Inventory class defines the private data fields, at least one constructor, accessor and mutator methods, method overloading (to handle the data coming into the Inventory class as either a String and/or int/float), as well as all of the methods (methods to calculate) to manipulate the Inventory class (object). The data fields...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { flavor = s; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         System.out.println(pepper.getFlavor());     } } a. a class variable b. a constructor c. a local object variable d....
What is the output of the following Java program? public class Food {     static int...
What is the output of the following Java program? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { s = flavor; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         pepper.setFlavor("spicy");         System.out.println(pepper.getFlavor());     } } Select one: a. sweet b. 1 c. The program does not compile. d. 2 e. spicy...
For this part, you will write a PostfixCalculator class that has methods for processing each possible...
For this part, you will write a PostfixCalculator class that has methods for processing each possible input. You will write a Tester class that reads a line of input from the user, with each symbol separated by a space, and prints out the numeric value of the top of the stack. If the user specifies an incomplete expression, print out the top of the stack and print out a message saying that the stack contains more than one item. If...
1. Consider the following interface: interface Duty { public String getDuty(); } a. Write a class...
1. Consider the following interface: interface Duty { public String getDuty(); } a. Write a class called Student which implements Duty. Class Student adds 1 data field, id, and 2 methods, getId and setId, along with a 1-argument constructor. The duty of a Student is to study 40 hours a week. b. Write a class called Professor which implements Duty. Class Professor adds 1 data field, name, and 2 methods, getName and setName, along with a 1-argument constructor. The duty...
Mention the concepts analyzed from the below given program and write the output. [0.5 M] class...
Mention the concepts analyzed from the below given program and write the output. [0.5 M] class Test { int a, b; Test(int i, int j) { a = i; b = j; } void meth(Test s) { s.a *= 2; s.b /= 2; } } class demo { public static void main(String args[]) { Test ob = new Test(15, 20); System.out.println("Before call: " + ob.a + " " + ob.b); ob.meth(ob); System.out.println("After call: " + ob.a + " " +...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • Question One: Basic security concepts and terminology                         (2 marks) Computer security is the protection of...
    asked 13 minutes ago
  • In program P83.cpp, make the above changes, save the program as ex83.cpp, compile and run the...
    asked 21 minutes ago
  • the determination of aspirin in commercial preparations experment explain why the FeCl3-KCl-HCl solution was ased as...
    asked 33 minutes ago
  • Describe important events and influences in the life of Wolfgang Amadeus Mozart. What styles, genres, and...
    asked 36 minutes ago
  • 3.12 Grade Statistics Write a python module "school.py" that prints school information (first 3 lines of...
    asked 37 minutes ago
  • Using python, please explain. The factorial of an integer N is the product of the integers...
    asked 41 minutes ago
  • alamoto Co. manufactures a single product that goes through two processes — mixing and cooking. The...
    asked 46 minutes ago
  • QUESTION 21 _______ is the ease of use with which network users can access the network...
    asked 51 minutes ago
  • Configure IP static routing using 6 pc's, 3 routers & 3 switches by using CISCO PACKET...
    asked 1 hour ago
  • Write a C++ program that calculates the series and parallel resistance for a group of resister...
    asked 1 hour ago
  • 1. A host computer is assigned the IP address 192.168.12.8 and a subnet mask of 255.255.255.192....
    asked 1 hour ago
  • Employees checking their cell phones and whispering to each other during a meeting are causing which...
    asked 1 hour ago