Java | Data Types | Question 1

filter_none

edit
close

play_arrow

link
brightness_4
code

class Main {   
   public static void main(String args[]) {      
         int t;      
         System.out.println(t); 
    }   
}

chevron_right


(A) 0
(B) garbage value
(C) compiler error
(D) runtime error


Answer: (C)

Explanation: Unlike class members, local variables of methods must be assigned a value to before they are accessed, or it is a compile error.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.