What is the output of the following Java program no. 5?
- class Test
- int i;
- public class Main
- public static void main (String args)
- Test test = new Test();
The output of the program is 0 because the variable i is initialized to 0 internally. As we know that a default constructor is invoked implicitly if there is no constructor in the class, the variable i is initialized to 0 since there is no constructor in the class.