Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following program contains several errors that violate the rules of Java: 1.

ID: 668859 • Letter: T

Question

The following program contains several errors that violate the rules of Java:
1. import java.awt.Color;
2. import java.awt.Graphics;
3. import java.awt.Point;
4. public abstract class Shape {
5. private Point position,
6. private Color color;
7. protected Shape(int x, int y, Color color) {
8. position = Point(x, y);
9. color = color;
10. }
11. /* Abstract methods
12. public abstract void draw(Graphics);
13. public abstract int getHeight();
14. public abstract int getWidth();
15. public int getX() {
16. return position.x;
17. }
18. public int gety() {
19. return position.y;
20. }
21. public moveHorizontal(int dx) {
22. position.x =+ dx;
23. }
24. public Color getColor() {
25. return Color;
26. }
27. }
Locate all the errors and specify whether each one is (a) lexical, (b) syntactic, or (c) se-mantic. Use the numbers shown to identify the line on which each error occurs. The program may also contain programming errors that do not violate the rules of Java and will not be detected by a Java compiler. You should ignore these errors.

Explanation / Answer

import java.awt.*; = syntactic error

public void absrcat (graphics ) =syntactic error

return color = this is semantic error

}

lexical error