I started learning myself Java fundamentals a few months ago (at the amateur level familiar with PHP
for several years).
To practise I use a OCA Java SE 8 Programmer 1 Study Guide and an example exam question is given which confuses me about use of curly braces and semicolons in if-statement
and can't find back in Java documentation.
I do not understand why answer E is allowed and compiles.
I've tried in Netbeans 10 (JDK 11) to evaluate warnings en hints but doesn't lead me to understand fundament.
Also trying multiple combinations that will compile ( only warning of Empty statement
).
if (true) ; {;;{}{}{}} ;;;;;;;;
if (true) ;;{}{{}{}{}}; {;;{}{}{}} ;;;;;;;;
if (true) ;;{}{{}{}{}}; {;;{}{}{}}
Question:Which of the following statements will not compile?
A. if (true) ;
B. if (true) {}
C. if (true) {;}
D. if (true) {;;}
E. if (true) ; {} ;
F. All statements will compile
(=correct answer)
Please help! Thanks in advance.