venerdì 29 marzo 2013

Q80

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
B.
default
C.
Compilation fails
D.
The program prints nothing
E.
An exception is thrown at run time
Risposta A .

Nessun commento:

Posta un commento