Welcome Guest | Sign in | Register
Objects and Collections - Discussion Page For Q.2903 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Objects and Collections > Questions and Answers

Exercise:

Section 1

Q: What will be the output of the program?
public class Test
{
public static void main (String args[])
{
String str = NULL;
System.out.println(str);
}
}
A. NULL B. Compile Error
C. Code runs but no output D. Runtime Exception

Answer and Explanation

Answer:Compile Error

Explanation:
Option B is correct because to set the value of a String variable to null you must use "null" and not "NULL".

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.