SCJP Module-4 Question-4


 

SCJP Module-4 Question-4

This program given below checks you knowledge of float in Java and shows how the values can be returned in float.

This program given below checks you knowledge of float in Java and shows how the values can be returned in float.

Given the following sample code:

class Example4{
public float Twin(float a, float b) {
return 0F;
}
public int Twin(int a, int b) {
return 0;
} }

Is the above sample code correct ?choose the correct reason  :

1. Incorrect , methods can't have the same name.

2. Incorrect , methods must not use same number of arguments.

3.Correct, method overloading is used.

4.Incorrect ,must use in different class.

Answer :

(3)

Explanation :

In method overloading ,same name methods can have same number of arguments but type must be differnt.

Ads