I’m learning Java and I just finished a Java quiz and on this test, there are actually two answers that would be correct , answer 1 and 2.
(Just in case the copy and paste doesn’t work, here’s the actual text)
========================================================
Which of the following lines would throw a compilation error?
- char grade_on_test = ‘F’;
- double isRaining = false;
- String gradeOnTest = “A”;
- int balance = -30;
1 and 2 will produce errors as both are incorrect Java, #2 is obvious as true or false is boolean, #1 because you can’t use underscores on variables at all in Java.
Both would produce errors to that effect, so either one would be a correct answer on this quiz to me. Any thoughts on why 2 is the preferred response?