Page 1 of 1

About Question com.enthuware.jfcja.v8.2.283 :

Posted: Sun Jun 07, 2020 3:34 pm
by kdemello1980
This question requires us to pick 3 options where the code compiles correctly, however, per the explanation, only 2 of the options are valid. What are we supposed to do when the instructions don't match the number of valid answers?

for( int i = 0; i< 0; i++) x = 3; is said to be a correct option, however later it says

"for( int i = 0; false; i++) x = 3; is also a compile time error because x= 3 is unreachable."

It seems like it is impossible to correctly answer this question.

Re: About Question com.enthuware.jfcja.v8.2.283 :

Posted: Mon Jun 08, 2020 12:20 am
by admin
Both, the correct options as well as the explanation, are correct.

Option 4 i.e. for( int i = 0; i< 0; i++) x = 3; is correct because it will compile without any error.

The explanation talks about unreachable code and then shows a variation of option 4, which fails compilation because of this issue. for( int i = 0; false; i++) x = 3; is not same as the statement in option 4.

We will enhance the explanation to make this clear.