SCJP Module-4 Question-6


 

SCJP Module-4 Question-6

The sample program given below tests your understanding of method overloading and method overriding in Java.

The sample program given below tests your understanding of method overloading and method overriding in Java.

Given the following sample code:

public class Example5{
public float Twin(float a, float b) {...
}
public float Twin(float a1, float b1) { ...}

}

How can above code will be corrected without changing the 'method's name', 'type' & 'number' of argument?

1.by changing the name of the argument.

2.by changing the body (code between braces)

3.by changing name of the class

4.by putting one method into another subclass of this class

Answer :

(4)

Explanation :

By putting one method into another subclass of this class, will correct this code. After this change overloading is converted into overriding.

Ads