8, [896] The following class contains four errors that violate the rules ofjava:
ID: 3755392 • Letter: 8
Question
8, [896] The following class contains four errors that violate the rules ofjava: public class Datef private int day; int month; private int year; public void setDay int day) ( this.day day; pubilc void setMonth (int month)( this.month month; public void setYear(double year) ( this.year- year; public String tostring()( return getMonth() +getDay)"getyear(); Circle and number each error in the source code. The use the lines below to describe each error and specify whether it is lexical, syntactic or semantic. Description Type 1. 2. 3. 4. Note: The class may contain programming errors that do not violate the rules of java.Explanation / Answer
Description Type Explaination 1 In set day method before parameter ( is missing Syntactic Error Syntax errors is basiccally occurs when java programming syntax is not respected. 2 Double to int conversion in set month method Sementic Error Sementic errors basically occurs when code syntax is correct but usage isn’t correct. 3 No get method defined in the code for month ,year or date but it is called in toString method for month ,year,date Sementic Error Sementic errors basically occurs when code syntax is correct but usage isn’t correct. 4 In toString method " is missing before +getYear() Syntactic Error Syntax errors is basiccally occurs when java programming syntax is not respected.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.