Open In App
Related Articles

Java | Data Types | Question 1

Improve Article
Improve
Save Article
Save
Like Article
Like




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


(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

Feeling lost in the vast world of Backend Development? It's time for a change! Join our Java Backend Development - Live Course and embark on an exciting journey to master backend development efficiently and on schedule.
What We Offer:
  • Comprehensive Course
  • Expert Guidance for Efficient Learning
  • Hands-on Experience with Real-world Projects
  • Proven Track Record with 100,000+ Successful Geeks

Last Updated : 29 Oct, 2018
Like Article
Save Article
Previous
Next
Similar Reads