AP Computer Science --- Haas --- ErrorMessages


/**
 * There are several types of errors, each with its own method 
 * of detection and repair. The basic types are:
 * 
 *     Syntax (compile-time) errors are errors in grammar and 
 *     punctuation such as mismatched quotes or missed commas. 
 *     These errors are caught by the javac compiler.
 *     
 *     Runtime errors only show up as the script is executed. 
 *     Common examples are calling a function that hasn't been declared 
 *     (typing error or case-sensitivity issue) or division by zero.
 *     
 *     Logic errors are basic errors in the programmer's algorithms or 
 *     procedural errors. Diagnosis only comes when incorrect results occur 
 *     and solution requires mapping out the flow for test cases. 
 *     The wrong scoping of a variable is an example of this kind of error. 
 *     
 *     Copy the folowing code into BlueJ:
 *     
 *     Fix each error in the program below and place a comment next to each 
 *     classifying as a compile-time, run-time, or logic error.
 */
class ErrorMessages {
    public static void main(String[] args) {
     
        int num1 = 1.1;
        int num2 = 0
        String name1 = "Joe";
        String name2 = "Jo";
        name2 = name2 + e;
        
        if (num1 / num2 == 1)
          System.out.println(num1 + " is the same as " + num2);
        else
          System.out.println(num1 + " is NOT the same as " + num2);
        
        if (name1 == name2) 
          System.out.println(name1 + " is the same as " + name2);
        else 
          System.out.println(name1 + " is NOT the same as " + name2);
        
    }
}