Question: For question 1 , consider that inside the class Sky, we have already coded the following: public class Sky { private Color color; public Sky(

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.

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!