Problem of the Day
Friday, October 9, 2026
Problem:
A Java program contains the following line of code.
int age = 17.3;
This line is an example of
- a syntax error
- a run-time error
- a logic error
- There are no errors in this code.
The correct answer is a. A syntax error is a violation of the "grammar rules" of the language, and in this case, trying to store a floating-point value in an int variable is not allowed.
Syntax errors are typically caught during the process of compiling the source code into bytecode, and are thus sometimes called compile-time errors.