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

Concepts of programming languages - P Please let me know if you need more time.

ID: 668841 • Letter: C

Question

Concepts of programming languages - P

Please let me know if you need more time. Thank you for your help!

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. 8. 9 10. protected Shape (int x, int y, Color color) ( position = Point (x, y); color = color; 11. /* Abstract methods 12. public abstract void draw (Graphics); 13. public abstract int getHeight (); 14. public abstract int getwidth); 15. public int getx()f 16 return position.x; 18. public int gety) f 19 20. return position.y; public moveHorizontal (int dx) ( 21. 22. 23. position . x ax; =+ 24. public Color getcolor() ( 25. 26. 27. ) return Color; Locate all the errors and specify whether each one is (a) lexical, (b) syntactic, or(c 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. ) se-

Explanation / Answer

line number 5 instead of , semi colon should be there. -- syntactic error.

Semantic error:

line number 8 and 9 use this.position and this.color because the current implementation will not be assigning the data members of the class.

line number 25 color variable should be used instead of Color.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote