answersLogoWhite

0

Semantic or Syntax errors are errors in the way a programmer has written his code. The code does not conform to language standards and is incorrect.

Ex:

for(int i = 0, i++, i<10) {

}

The above is a syntactically incorrect declaration of a for loop in Java. The compiler would not let you compile this code successfully.

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

ReneRene
Change my mind. I dare you.
Chat with Rene
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
More answers

A semantic error is one that will not be caught by the compiler (it is not a syntax error), but will produce undesirable or unpredictable results during the execution of the program. For example, a loop that uses "while(x = 5)" will still compile, but will run indefinitely, because x will be set to 5 each time, and any non-zero value will continue a while loop. Assuming x is used within the loop, it would also produce erroneous results.

User Avatar

Wiki User

12y ago
User Avatar

Add your answer:

Earn +20 pts
Q: What are Semantic errors in a programming language?
Write your answer...
Submit
Still have questions?
magnify glass
imp