This is for programming language concept. Please answer correctly. there are man
ID: 3905859 • Letter: T
Question
This is for programming language concept. Please answer correctly. there are many errors
5. The following class contains several errors that violate the rules of Java: 1. public class Fraction 2. private int numerator; 3. private int denominator; . public Fraction(int num, int denom) numerator num; denominator denom; reduce)i 9 public Fraction(int num) 10. this(num, 1) 2. public Fraction) 13 14. this(0 15. public int getdenominator 16 retrun denominator; 18. pulbic Int getNumerator ) 19 20 return numerator; 21. public double toDoulbe ) 22. return (double) numerator (double denominator; 23. 24. public float toFloat 25 return (float) numerator / denominator; 26. 27. public String toString ) 28 29 30 31 32. if (denominator == 1) return numerator'* else return numerator"/"+ denominator; 33. void reduce) ( 34 35. 36 37 38 int ggdc (numerator, denominator); if(g!=0) numerator - g denominator/ g 39 40 if (denominatorExplanation / Answer
In line 29 the error is ' instead of ". it is snytactic
In line 34 the error is gdc instead of gcd and it is lexical
Line 44 has error as it doesn't specify the data type for n is not specified.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.