In: Computer Science
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;
}
}
public Color getColor();
Is this method a constructor, mutator or accessor?
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.
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.
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.
1.
Solution:
2.
Solution:
The reconstruction of the header is provided below:
public static void foo3(double value);
3.
Solution:
The reconstruction of the header is as follows:
public int foo4(String s);
The function return an integer value and having the String as its parameter.
4.
Solution: