Discussion Forum : Strings
Question - Determine output:
public class Test{
public static void main(String args[]){
String str = null;
if(str.length() == 0){
System.out.print("1");
}
else if(str == null){
System.out.print("2");
}
else{
System.out.print("3");
}
}
}
Options:
A .  Compilation fails.
B .  "1" is printed.
C .  "2" is printed.
D .  "3" is printed.
E .  An exception is thrown at runtime.
Answer: Option E

Submit Your Solution Below and Earn Points !
Submit Your Solution hear:

Your email address will not be published. Required fields are marked *