r/learnjava • u/TexhnicalTackler • Jan 25 '26
Got this question wrong today and it's bugging me a little bit, any thoughts?
This is my second semester taking coding classes, last semester was python and this semester we pivoted to java, Friday was my first quiz but this question is throwing me off.
---------------------
Assume the programmer wishes to display "Hello!" on the screen, which statement is true about the following java code fragment:
System.out.println("Helo!");A) There is a runtime error
B) There are no error
C) There is a compile-time error
D) There are multiple errors
---------------------
From my understanding of python and the lack of any observable difference in my current classes, I don't see how a typo in the string consitutes a runtime error, and with the lack of noticable compiling errors I answered (B), only for the answer to be wrong and it come back as (A)? Every piece of documentation I've looked at says this would be a syntax error at worst
View all comments
-3
u/TheGreatRao Jan 25 '26
Hear me out. It is a run-time error. The program is supposed to do A ("Hello"), it does B ("Helo"). It successfully compiles, and runs, but does not do what it is supposed to do. (B) is the answer. Think of it like this: the assignment says create a method called "DrawColor" to display a red background. Your program calls DrawColor, and the background at run-time is blue. How can there be no error?