Confusion in Question
Posted: Wed Dec 04, 2013 7:55 am
Hi!
Wanna tell you about the incorrect answer to the following question:
Consider the following class...
class TestClass{
void probe(Integer x) { System.out.println("In Integer"); } //2
void probe(Object x) { System.out.println("In Object"); } //3
void probe(Long x) { System.out.println("In Long"); } //4
public static void main(String[] args){
String a = "hello";
new TestClass().probe(a);
}
}
What will be printed?
It's obviously that the answer is: "In Object".
But etsviewer tells us that we are wrong and that: "It won't compile"!
Wanna tell you about the incorrect answer to the following question:
Consider the following class...
class TestClass{
void probe(Integer x) { System.out.println("In Integer"); } //2
void probe(Object x) { System.out.println("In Object"); } //3
void probe(Long x) { System.out.println("In Long"); } //4
public static void main(String[] args){
String a = "hello";
new TestClass().probe(a);
}
}
What will be printed?
It's obviously that the answer is: "In Object".
But etsviewer tells us that we are wrong and that: "It won't compile"!