1/36
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is Object-Oriented Programming (OOP)?
A programming paradigm that organizes code using objects and follows four main principles: abstraction, encapsulation, inheritance, and polymorphism.
What is abstraction?
Hiding complex implementation details and showing only essential features.
What is encapsulation?
Wrapping data and methods into a class and restricting access using access modifiers.
What is inheritance?
When a class inherits fields and methods from another class (a parent class).
What is polymorphism?
Using a single interface to represent different types, enabling method overriding and overloading.
What does abstraction focus on?
What an object does, not how it does it.
Why is abstraction useful?
It helps manage complexity and lets us use objects without knowing their internal workings.
How is abstraction implemented in Java?
Using abstract
classes and methods.
What does encapsulation do?
Hides data and only allows controlled access through public methods.
How is encapsulation implemented in Java?
Using private
variables and public
getter/setter methods.
Why is encapsulation important?
It protects data from being changed incorrectly and bundles state + behaviour.
What does inheritance allow in Java?
A child class to reuse code from a parent class.
What kind of relationship is inheritance?
An "is-a" relationship.
What does a subclass inherit from its superclass?
All non-private fields and methods.
Can a subclass override inherited methods?
Yes — using the same method signature.
What does polymorphism allow?
A subclass object to be treated as an object of its parent class.
What are the two types of polymorphism?
Method overriding and method overloading.
Is this valid? Animal a = new Dog();
Yes — because Dog
is an Animal
.
Is this valid? Dog d = new Animal();
No — because not all Animals
are Dogs
.
What are UML class diagrams used for?
To visualize classes, their attributes, methods, and relationships.
What symbol means public in UML?
+
What symbol means private in UML?
-
How is an attribute shown in UML?
name : type
How is a method shown in UML?
methodName(parameters) : returnType
What is association?
A general relationship between two independent classes.
What is aggregation?
A "has-a" relationship where the contained object can exist independently.
What is composition?
A "has-a" relationship where the contained object cannot exist without the container.
Example of aggregation?
A Library
has many Books
, but a Book
can exist on its own.
Example of composition?
A House
has Rooms
, and if the house is destroyed, so are the rooms.
What is bidirectionality?
Whether both classes in a relationship know about each other.
What is a unidirectional relationship?
Only one class holds a reference to the other.
What is a bidirectional relationship?
Both classes hold references to each other.
What is multiplicity in class relationships?
It describes how many instances of one class relate to instances of another.
What does 1 mean in multiplicity?
One-to-one relationship.
What does 0..1 mean?
Zero or one instance.
What does 0..* mean?
Zero or many (optional).
What does 1..* mean?
One or many (mandatory).