Option D Flashcards
Outline the general nature of an object.
In general an object can be defined as a location in memory having a value. This could be a variable or data structure. Usually when talking about objects it refers to instances of a class.
What are the three rows of a UML diagram?
- Class name
- Variables
- Methods
What is the structure of a variable in a UML diagram?
varName : type ( = value)
What are the three types of relationships between objects?
The three types of relationships that should be known are dependency (“uses”), aggregation (“has a”) and inheritance (“is a”).
Explain aggregation.
Aggregation is a type of relationship between objects. It means that one type of object contains another or is composed of another. Some examples are: a car has-an engine, a bicycle has-a wheel, and a coffee cup has coffee.
Explain inheritance.
Inheritance is a type of relationship between objects. It means that one type of object is a more specific version of a general type. Some examples are: a car is-a vehicle, a bicycle is-a vehicle, and a coffee cup is-a cup.
Explain dependency.
Dependency is a type of relationship between objects. It means that during some activity, one type of object uses another type of object. Some examples are: a car uses-a squeegee (during a window-washing activity), a bicycle uses-a pump (during a tire-pumping activity), and a coffee cup uses-a stirrer (during a stirring activity).
How are dependency and aggregation represented in a UML diagram with multiple classes?
In UML: A dependency (when one dies, the other dies) is represented by a shaded diamond
An aggregation is represented by a hollow diamond
What are the two parts of an object?
- Attributes (variable names)
2. Behaviour (Methods)
What are the four fundamental OOP concepts?
- Encapsulation
- Abstraction
- Inheritance
- Polymorphism
Encapsulation and abstraction are _____ concepts.
Complementary
What’s the major difference between abstraction and encapsulation?
Just like abstraction, encapsulation hides data, but at a deeper level.
What is encapsulation?
Encapsulation is the process of combining data and methods into a single unit (class). In Encapsulation, the data is not accessed directly; it is accessed through the methods present inside the class. In simpler words, attributes of the class are kept private and public getter and setter methods are provided to manipulate these attributes. Thus, encapsulation makes the concept of data hiding possible.
What is inheritance?
Inheritance enables programmers to define an “is-a” relationship between a class and a more specialized version of that class. For example, if a Student class extends a Person class, then it should be the case that Studentis-aPerson. The subclass Student builds on the functionality of the superclass Person.
If a parent class is shapes, list some child classes it can have?
triangle, rectangle etc.