giovedì 28 marzo 2013

Q73

Given the code fragment:
public class TestStudent {
       public static void main(String[] args) {
             String valid = "true";
             if (valid)
                    System.out.println("valid");
             else
                    System.out.println("not valid");
       }
}

What is the result?
A.
Valid
B.
not valid
C.
Compilation fails
D.
An IllegalArgumentException is thrown at run time
Risposta C. Non viene fatto alcuna cast automatico tra stringa e booleano.

 

Nessun commento:

Posta un commento