a.
(i)
An object in programming encapsulates data and behavior into a single unit. It has
attributes (states) and methods (behavior) that operate on that data. Objects interact
with each other through methods, and they can be created, modified, and destroyed
during program execution.
(ii) Two disadvantages of using Object-Oriented Programming (OOP) are:
Overhead: OOP can introduce additional complexity and overhead, especially in
large-scale systems. Object creation, method dispatching, and memory management can
incur performance costs compared to procedural or functional programming paradigms.
Complexity: OOP encourages abstraction and encapsulation, which can lead to
complex class hierarchies and relationships. Understanding and maintaining such
systems can be challenging, especially for new developers or when the design is not well-
structured.
(iii) One advantage of using modularity in program development is that it promotes code
reuse and simplifies maintenance. By breaking down a program into smaller, modular
components, each responsible for a specific task or functionality, developers can easily
identify, debug, and update individual modules without affecting the entire system. This
enhances flexibility, scalability, and collaboration in software development.
(b) UML diagram representing the Arrival object:
___________________________________________
| Arrival |
|__________________________________________|
| - myFlight: Flight |
| - sta: String |
| - runway: int |
| - gate: String |
| - delay: int |
| - landed: boolean |
|__________________________________________|
| + Arrival(myFlight: Flight, sta: String) |
| + addDelay(newDelay: int) |
| + getETA(): String |
| + compareWith(flightID: String): int |
| + compareWith(anotherArrival: Arrival): int |
|__________________________________________
(с) Method signature refers to the unique combination of a method’s name and
parameter list. It includes the method’s name along with the number, types, and order of
its parameters. The return type is not considered part of the method signature.
(d) Calling the compareWith method does not cause a conflict because the two methods
have different parameter lists. One method compares the Arrival object with a String
flightID, while the other compares the Arrival object with another Arrival object. Java
allows method overloading, where multiple methods can have the same name but different
parameter lists. The method to be invoked is determined based on the number and types of
arguments provided in the method call.