Which of the statements regarding the following code are correct?
publicclass Main {
staticint a;
int b;//fromwww.java2s.compublic Main() {
int c;
c = a;
a++;
b += c;
}
publicstaticvoid main(String args[]) {
new Main();
}
}
Select 1 option
A. The code will fail to compile because the constructor is trying to access static members.
B. The code will fail to compile because the constructor is trying to use static member variable a before it has been initialized.
C. The code will fail to compile because the constructor is trying to use member variable b before it has been initialized.
D. The code will fail to compile because the constructor is trying to use local variable c before it has been initialized.
E. The code will compile and run without any problem.
Correct Option is : E
Note
All the instance or static variables are given a default values if not explicitly initialized.
All numeric variable are given a value of zero or equivalent to zero (i.e. 0.0 for double or float ).
booleans are initialized to false and objects references are initialized to null.