martedì 29 ottobre 2013

Q22

Given:
             StringBuffer b = new StringBuffer("3");
            System.out.print(5+4+b+2+1);
 
What is the result?
 
A.
54321
 
B.
9321
 
C.
5433
 
D.
933
 
E.
Output is Similar to: 9java.lang.StringBuffer@100490121.
 
F.
Compilation fails.
                  
La risposta è F perchè The operator + is undefined for the argument type(s) int, StringBuffer .
Si potrebbe far compilare il codice in questo modo :
System.out.print(5+4+b.toString()+2+1);   

Nessun commento:

Posta un commento