0

Java query for method overloading

What should be proper output for this code? According to me it should produce compilation error or exexute the first method only! Can somebody explain this paradox? https://code.sololearn.com/cV5Xkw3OJi9y/?ref=app

1st May 2019, 12:55 PM
Abhay Jindal
Abhay Jindal - avatar
1 Answer
+ 2
Try this: public static void doCalc(byte s1, byte s2) { System.out.print("Byte, Byte"); } Byte s1, Byte s2 --> I think method expects an object Byte (Byte is not byte) Maybe it works because a byte number fits into long --> kind of parsing byte to long but I am not really sure
1st May 2019, 1:07 PM
Denise Roßberg
Denise Roßberg - avatar