Mock TCA CSY2094 Systems Design
Mock TCA CSY2094 Systems Design
(i) Relationships in Class Diagrams indicate that there are links required by
(a) Association
(b) Aggregation
(c) Composition
(d) Inheritance
(1,1,2,2)
(ii) Create a class diagram to satisfy the following specification for an online
hotel
booking system:
The system has multiple users, each with a name and contact number. There
Each hotel room has a room number, room type, and price per night. Guests
(15)
b. Create a subclass called Car that extends Vehicle with the following
properties:
• An attribute horsepower.
• A constructor that takes a parameter to set the horsepower attribute.
c. Create a main method to create a Car object and call its maxSpeed()
method.
(3, 10, 5)
having attributes like id, name, salary, and department. The program should
perform
the following operations: first, add five Employee objects to the list. Calculate
and
(11)
(a) Association
(b) Aggregation
(d) Inheritance
+----------------+ +----------------+
| User | | Room |
+----------------+ +----------------+
/\ +----------------+
| /\
| |
+------+-------+ +-----+------+
| | | |
| +---------+ | +-------+--------+ |
| | Guest | | | HotelManager | |
| +---------+ | +----------------+ |
+--------------+ | |
| | |
| | |
v v |
+----------------+ | |
| Reservation |<-------+ |
+----------------+ |
| - checkInDate: Date | |
| - checkOutDate: Date | |
+----------------+ |
Notes:
}
b. Create a Car subclass:
this.horsepower = horsepower;
return horsepower * 2;
The maximum speed would be 200 mph for a Car object with 100
horsepower.
import java.util.ArrayList;
class Employee {
this.id = id;
this.name = name;
this.salary = salary;
this.department = department;
return salary;
double totalSalary = 0;
totalSalary += emp.getSalary();
1. super
2. this
o Prevents inheritance
3. extends
4. final
for loop ✓
do-while loop
switch statement
while loop
int x;
public MyClass() {
x = 5;
System.out.println(obj.x);
Compilation error
5✓
0
Runtime error
this.make = make;
this.model = model;
return model;
inheritance ✓
polymorphism
encapsulation
abstraction
To declare a variable
True
False ✓
switch case
for loop
if statement ✓
while loop
True
False ✓
interfaces
Association
Aggregation
Composition
Inheritance
Expected answers:
Abstract Shape class with color attribute and abstract area() method
Circle and Rectangle classes that extend Shape
Main method that creates and displays information about both shapes
Uses an ArrayList to store Book objects with title, author, and price
Main method that adds at least 3 books and displays the total
What will be the output of the following code? Explain your answer.
System.out.println("Parent display");
@Override
System.out.println("Child display");
super.display();
this.display();
}
public class Main {
c.show();
1. super
2. this
o Prevents inheritance
3. extends
o Implements an interface
4. final
for loop ✓
do-while loop
switch statement
while loop
int x;
public MyClass() {
x = 5;
System.out.println(obj.x);
Compilation error
5✓
0
Runtime error
Question 4: What does the getModel() method return?
this.make = make;
this.model = model;
return model;
inheritance ✓
polymorphism
encapsulation
abstraction
To declare a variable
To create a new instance of a class
True
False ✓
switch case
for loop
if statement ✓
while loop
True
False ✓
interfaces
constructors