Q17
Given:
class X {
String str = "default";
X(String s) {
str = s;
}
void print() {
System.out.println(str);
}
public static void main(String[] args) {
new X("hello").print();
}
}
What is the
result?
A.
hello
hello
B.
default
default
C.
Compilation fails
Compilation fails
D.
The program prints nothing
The program prints nothing
E.
An exception is thrown at run time
La risposta è A : hello.
riferimento : http://1z0-803.blogspot.it/2013/04/costruttori.html
An exception is thrown at run time
La risposta è A : hello.
riferimento : http://1z0-803.blogspot.it/2013/04/costruttori.html
Nessun commento:
Posta un commento