Presentation is loading. Please wait.

Presentation is loading. Please wait.

Compiler Errors Syntax error Lexical Can not resolve/find symbol Can not be applied Execution error Oh wait, a run time error Intent error It ran, but.

Similar presentations


Presentation on theme: "Compiler Errors Syntax error Lexical Can not resolve/find symbol Can not be applied Execution error Oh wait, a run time error Intent error It ran, but."— Presentation transcript:

1

2 Compiler Errors Syntax error Lexical Can not resolve/find symbol Can not be applied Execution error Oh wait, a run time error Intent error It ran, but it did not accomplish the task

3 Syntax error Missing semicolons ; Unmatched/missing parenthesis ( ) Unmatched curly braces { } Misspelled reserved words What are reserved words? They are words that have special meaning in Java. A few examples: public, class, void, static, main, new

4 Lexical Errors Can not resolve symbol What’s a symbol Identifier For example: reference name – karel, … Method name For example: turnLeft(), move(), … Anything that follows the. In a Robot name Class name For example: Robot, IceSkater, Mana, Magnet, (Alice) Type Matching Classes – more later.

5 Lexical Errors Can not resolve symbol Identifier not declared Misspelled class robot instead of Robot Misspelled identifier Robot karel = new Robot(); Karle.move(); Karel.turnLeft();

6 Lexical Errors Can not resolve symbol Continued: Asking an Object to perform a task it does not recognize Robot karel = new Robot(); karel.turnRight(); karel.mve(); karel.turnleft();

7 Lexical Errors Can not be applied Type mismatch Giving a method the incorrect number/type of parameters

8 Lexical Errors Can not be applied Type mismatch Robot karel HurdlerRobot student = new HurdlerRobot(); student = karel;  HurdlerRobot can not be applied to Robot  HurdlerRobot can do more than a Robot? Student.turnRight(); //student can tR, but can a Robot?

9 Lexical Errors Can not be applied Giving a method the incorrect number/type of parameters karel.move(5);  move(int) can not be applied to move(void)

10 Lexical Errors Can not be applied - Again Taking it a step further Consider the method Lab03.takeTheField(Athlete arg) Robot karel = new Robot(); Lab03.takeTheField(karel); Compile error, takeTheField(Robot) can not be applied to takeTheField(Athlete)

11 Execution Errors Oh wait, a run time error No compiler error, but the program terminates during execution For example: Robot with no beepers attempts to put a beeper Robot tries to pick beeper with no beepers Robot tries to walk through a wall Divide by zero

12 Intent Error Logic error Program gracefully terminates No run time exception Guess who catches this error If you answered myself (the student), you can earn more points by fixing the error. If you answered the teacher, you will lose points!

13 Summary Syntax error Robot karel = new Robot(); karel. move() // spaces & ; karel.move; // () Lexical Can not resolve/find symbol KAREL.move; // misspelling identifier Robot sam = new robot(); // misspelled Robot

14 Summary Lexical Can not be applied Robot karel = new Robot(1.5, 2, West, 0); Can not apply double (1.5) to int int look like Integers (no decimal point) double have a decimal point with or without numbers following Karel.turnLeft(3); can not apply int to void void means that no argument/parameter expected

15 Summary Execution Error It runs - it dies while executing Move through walls beeper issues Unsafe methods move(), pickBeeper(), putBeeper() Safe Methods turnLeft() What about turnRight()?

16 A final word First the compiler checks syntax Then the compiler checks all symbols Remember what symbols are? Then the compiler checks if it can apply what it has been asked. If the answer to all the above is yes, Run the program and see what happens


Download ppt "Compiler Errors Syntax error Lexical Can not resolve/find symbol Can not be applied Execution error Oh wait, a run time error Intent error It ran, but."

Similar presentations


Ads by Google