Objects and Collections

Q1: 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

ANS:A - NULL

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



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.