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.
Answer.)
To Compile Class 2, the below methods needs to be overridden :
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.
Get Answers For Free
Most questions answered within 1 hours.