222CCS Quiz 2 R1
222CCS Quiz 2 R1
222CCS Quiz 2 R1
222CCS - Page 1 of 4
Q2) Correct the following program ( Please note: false correction will affect your grade) :
class Car {
public class const int MAX_DOOR_NUMBER = 4;
private Person owner;
public Person() {
name = "default";
age = 0;
}
else
System.out.println(car1.getOwnerName()" has a small car");
OUTPUT:
222CCS - Page 2 of 4
Q3) Write a Java program that fulfill the following state diagram:
Room
- WindowNum: int
- length: double
- width: double
Then:
1) Add a public class constant which set the maximum area to 40.0
2) Add another constructor with no parameters.
3) Add the main method to the class Room and define at least three objects, named r1, r2, and r3.
4) From the main method, test if r1, r2, and r3 have larger area than the class constant or not, and
print “Big Room” or “Small Room”, accordingly.
222CCS - Page 3 of 4
222CCS - Page 4 of 4