Which of the following is the default value of an int variable declared as an instance variable?
- 0
- 1
- -1
- The default value depends on the specific situation.
In Java, the default value of an instance variable of type int is 0. This is true for all numeric types in Java. The other options are not the default values for int instance variables.
Loading...
Related Quiz
- Can a constructor return a value in Java?
- Can a constructor be private in Java?
- What is the significance of declaring a variable as transient?
- What is the purpose of the finally block in Java exception handling?
- The class ________ allows an application to write primitive Java data types to an output stream in a portable way.