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

For question 1 , consider that inside the class Sky, we have already coded the f

ID: 3748301 • Letter: F

Question

For question 1 , consider that inside the class Sky, we have already coded the following:

    public class Sky

     {

        private Color color;

        public Sky( Color c)

          {

              color = c;

          }

      }

(20 pts) Consider the following method header:

    public Color getColor();

Is this method a constructor, mutator or accessor?

2. (20 pts) Inside a method main, we see code like:

     Airplane.foo3(34.6);

From this, reconstruct the header of method foo3 (which belongs to class Airplane); make appropriate assumptions if necessary. Write the method header as your answer.

              

3.(20 pts) Inside method main, we see code like:

Airplane a = new Airplane();

int n = a.foo4(“Hello”);

From this, reconstruct the header of method foo4 (which belongs to class Airplane)

Write the method header as your answer.

4. (40 pts) You coded the following class:

You coded the following definition for the class Grade:

public class Grade

{

private char letterGrade;

public Grade(char 1g)

{

     letterGrade = lg;

   }

public String toString() //line 10

   {                                  //line 11

       return letterGrade;    //line 12

}                                    //line 13

}

When you compile, you get the following message:

Grade.java:12: incompatible types

return letterGrade;

           ^

found : char

required: String

1 error

Explain what the problem is and how to fix it.

Explanation / Answer

Answer 1:
public Color getColor() is accessor which is used to access the elements
Answer 2:
public static void foo3(double d){
}
Answer 3:
public int foo4(String str{
}
Answer 4:
The problem is letterGrade is an char and toString() return type is an String so convert letterGrade to string by simply appending the ""+
public class Grade

{

private char letterGrade;

public Grade(char 1g)

{

letterGrade = lg;

}

public String toString() //line 10

{ //line 11

return letterGrade+""; //line 12

} //line 13

}

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