What is the result?

Given:

public class Yikes {

public static void go(Long n) {
System.out.print(“Long “);
}

public static void go(Short n) {
System.out.print(“Short “);
}

public static void go(int n) {
System.out.print(“int “);
}

public static void main(String[] args) {
short y = 6;
long z = 7;
go(y);
go(z);
}
}

What is the result?

Given:

public class Yikes {

public static void go(Long n) {
System.out.print(“Long “);
}

public static void go(Short n) {
System.out.print(“Short “);
}

public static void go(int n) {
System.out.print(“int “);
}

public static void main(String[] args) {
short y = 6;
long z = 7;
go(y);
go(z);
}
}

What is the result?

A.
int Long

B.
Short Long

C.
Compilation fails.

D.
An exception is thrown at runtime.



Leave a Reply 1

Your email address will not be published. Required fields are marked *