Question: Debug the following program that has scope violations. Then, add comments that label the variable declerations as class, method, or blocm scope. 1 public class

Debug the following program that has scope violations. Then, add comments that label the variable declerations as class, method, or blocm scope. Debug the following program that has scope violations. Then, add comments that

1 public class Testerclass 2 { 3 public static void main(String[] args) 4 5 6 Fraction f1 = new Fraction(); Fraction f2 - new Fraction(1,2); System.out.println(f1); System.out.println(f2.numerator / f2.denominator); 7 8 3 9 10 11 12 /* Class Fraction 13 class Fraction 14 15 W instance variables private int numerator; 17 private int denominator; 16 18 19 il constructor: set instance variables to default values public Fraction() 20 { 22 int d - 1; numerator - d; denominator - di 25 26 27 28 29 30 31 32 33 34 35 36 37 // constructor: set instance variables to init parameters public Fraction(int initNumerator, int initDenominator) { numerator - initNumerator; denominator - initDenominator; } public String toString() { // if the denominator is 1, then just return the numerator if (denominator -- d) { int newNumerator - 1; 3 return newNumerator + "/" + denominator; 38 39 (42)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!