I saw this one question in the scjp tutorial.
public class Yikes { public static void go(Long n) { System.out.println("Long "); } public static void go(Short n) { System.out.println("Short "); } public static void go(int n) { System.out.println("int "); } public static void main(String [] args) { short y = 6; long z = 7; go(y); go(z); } }
The output is int Long .
I pass the short datatype variable to the overloaded go method. You now have a short version. Then, how is the call with int called? What is the reason for this behavior?
I am new to java. So please help me here.
source share