To begin, I apologize about my English, it's not my mother language...sorry for all mistakes...
I'm starting to read the OCA
Java SE8 Programmer 1 and I have a question about the initialization order.
Could you please have look at this code :
1 - If the "number" declaration is in the comments (//private int number=3;), the code doesn't compile.
There is an error at the line : "number=4;" because "number" is undeclared.
2 - After removing the comments, when I execute this code, the result is "number :3".
My question is :
- when the statement "{number=4;}" is executed ?
If it is executed in first, I think the program should have to crash because the variable is not declared.
If it is executed after the declaration/affectation statement, the result displays should be "number :4"...
It seems this statement is never executed. I'm right ? Is it possible ?
Thank you for your help. Regards
Anne