Programming Errors
Errors that are detected by the compiler are called syntax errors or compile errors.
Program : ShowSyntaxErrors.java
Error1: Invalid method declarations: return type required (void is missing at line3)
Error2: Unclosed string literal (string is not enclosed with double quotes in print statement at line 4)
Common Error 1: Missing Braces
Common Error 2: Missing Semicolons
Common Error 3: Missing Quotation Marks
Common Error 4: Misspelling Names
2.Runtime Errors
Runtime errors are errors that cause a program to terminate abnormally. For instance, if the program expects to read in a number, but instead the user enters a string, this causes data-type errors (input errors) to occur in the program. Another example of runtime errors is division by zero.
Program : ShowRuntimeErrors.java
3.Logic Errors
Logic errors occur when a program does not perform the way it was intended to.
You will get Fahrenheit 67 degrees, which is wrong. It should be 95.0. In Java 9 / 5 is 1. To
get the correct result, you need to use 9.0 / 5, which results in 1.8.
Comments
Post a Comment