1.
class Test {
void show(int a) { }
void show(long a) { }
public static void main(String[] args) {
Test t = new Test();
t.show(10);
}
}
ANSWER: show(int a)
2.
class Test {
void show(Integer a) { }
void show(int a) { }
public static void main(String[] args) {
Test t = new Test();
t.show(10);
}
}
ANSWER: show(int a)
3.
class Test {
void show(int a, float b) { }
void show(float a, int b) { }
public static void main(String[] args) {
Test t = new Test();
t.show(10, 10);
}
}
ANSWER: Compile-time Error
4.
class Test {
void show(int... a) { }
void show(int a) { }
public static void main(String[] args) {
Test t = new Test();
t.show(10);
}
}
ANSWER: show(int a)
5.
class Test {
void show(int a) { }
void show(int... a) { }
public static void main(String[] args) {
Test t = new Test();
t.show();
}
}
ANSWER: show(int... a)
6.
class Test {
void show(double a) { }
void show(float a) { }
public static void main(String[] args) {
Test t = new Test();
t.show(10);
}
}
ANSWER: compile time error
7.
class Test {
void show(Object o) { }
void show(String s) { }
public static void main(String[] args) {
Test t = new Test();
t.show(null);
}
}
ANSWER: show(String s)
8.
class Test {
void show(String s) { }
void show(Integer i) { }
public static void main(String[] args) {
Test t = new Test();
t.show(null);
}
}
ANSWER: show(String s)
9.
class Test {
void show(int a, int b) { }
void show(int... a) { }
public static void main(String[] args) {
Test t = new Test();
t.show(10,20);
}
}
ANSWER: show(int a, int b)
10.
class Test {
void show(int a) { }
static void show(int a) { }
public static void main(String[] args) {
Test t = new Test();
t.show(10);
}
}
ANSWER: Compile time error
11.
class Test {
void show(long a) { }
void show(float a) { }
public static void main(String[] args) {
new Test().show(10);
}
}
ANSWER: compile time error
12.
class Test {
void show(int a) { }
void show(int a, int... b) { }
public static void main(String[] args) {
new Test().show(10);
}
}
ANSWER: show(int a)
13.
class Test {
void show(char c) { }
void show(int i) { }
public static void main(String[] args) {
new Test().show('A');
}
}
ANSWER:show(char c)
14.
class Test {
void show(byte b) { }
void show(short s) { }
public static void main(String[] args) {
byte b = 10;
new Test().show(b);
}
}
ANSWER:show(byte b)
15.
class Test {
void show(Object o) { }
void show(String s) { }
void show(CharSequence c) { }
public static void main(String[] args) {
new Test().show("Java");
}
}
ANSWER:show(String s)
Top comments (0)