What is the default value of an int in Java?

Java MCQ: What is the default value of an int in Java?

a) 0
b) null
c) 1
d) -1

Answer:

a) 0

Explanation:

The default value of an int in Java is 0. When an int variable is declared but not initialized, it automatically gets assigned the value 0.

Understanding default values helps prevent unexpected behavior and errors in your Java programs.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

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

Scroll to Top