TOPUPchat logo...
Forgot password?

Select : C language | Java

Q.10] precidence in calling overloaded methods in java

public class Test {    

public void print(byte x) {     

System.out.print("object");
    }

public void print(int x) {

System.out.print("float");

}

public void print(float x) {

System.out.print("int");

}

public void print(Object x) {

System.out.print("byte");

}

public static void main(String a[]){

Test t = new Test();

short s = 123;

t.print(s);

t.print(12345L);

t.print(6.789);

}
}

    

Options]

A)intfloatobject
B)floatintbyte
C)objectfloatint
D)compile time error        

Click to See Answer
B)floatintbyte    

Next | type casting of int in char or not

Previous | calling system.out.print insode of system.out.print

Hemen Ashodia [paper setter]
Register & recharge
Male Female
I agree Terms and Conditions