Given:
class Overloading {
void x(int i) {
System.out.println("one");
}
void x(String s) {
System.out.println("two");
}
void x(double d) {
System.out.println("three");
}
public static void main(String[] args) {
new
Overloading().x(4.0);
}
}
What is the
result?
A.
One
One
B.
Two
Two
C.
Three
Three
D.
Compilation fails
Compilation fails
Risposta C
Visto che si passa un double al costruttore viene usato il
costruttore per i double e quindi si ha la stampa di Three .
Nessun commento:
Posta un commento