Java Reference
In-Depth Information
Figure 8-25 gives the UML class diagram of a class. Answer the following
questions.
2.
State
-name: String
-population: int
-area: double
+State()
+State(String, int , double )
+setName(String): void
+getName(): String
+setPopulation( int ): void
+getPopulation(): int
+setArea( double ): void
+getArea(): double
+toString(): String
+makeCopy(State): void
+getCopy(): State
FIGURE 8-25 UML diagram
8
a. What is the name of the class?
b. What are the instance variables?
c. What are the methods?
d. What are the private members?
e. What are the public members?
Find the syntax errors in the definition of the following class:
public class AA
{
3.
private int x;
private int y;
public void print()
{
System.out.println(x + " " + y);
}
public int sum()
{
return x + y;
}
Search WWH ::




Custom Search