Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views1 page

Oop Test Answers

The document explains the concept of objects in programming, highlighting their attributes and methods, as well as their interactions. It discusses the disadvantages of Object-Oriented Programming (OOP), such as overhead and complexity, and emphasizes the advantages of modularity for code reuse and maintenance. Additionally, it describes a UML diagram for an Arrival object and clarifies method signatures and method overloading in Java.

Uploaded by

grossak4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Oop Test Answers

The document explains the concept of objects in programming, highlighting their attributes and methods, as well as their interactions. It discusses the disadvantages of Object-Oriented Programming (OOP), such as overhead and complexity, and emphasizes the advantages of modularity for code reuse and maintenance. Additionally, it describes a UML diagram for an Arrival object and clarifies method signatures and method overloading in Java.

Uploaded by

grossak4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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.

You might also like