r/learnjava • • 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

12 Upvotes

29 comments sorted by

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?

7

u/fakeacclul Jan 25 '26

Unless that piece of code throws a Runtime exception, this question is just stupid

4

u/MagicalPizza21 Jan 26 '26

There's an error, a typographical error. Maybe you could stretch the definition of semantic error to cover this. But the code compiles and runs smoothly without crashing so there's no runtime error here.

1

u/TheGreatRao Jan 26 '26

Thanks for the update. I only code for fun, so I've never even completed DSA and appreciate the feedback.

-5

u/QQut Jan 25 '26

this.

Who says test is wrong, clearly lacks fundementals.