Past paper (OOP) Flashcards

(14 cards)

1
Q

What is inheritance in OOP?

A

Subclasses inherit attributes & methods from parent classes, promoting code reuse and hierarchy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is polymorphism in OOP?

A

Objects of different classes can be treated as instances of a common superclass or interface.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does polymorphism add flexibility?

A

Same method call behaves differently depending on object class implementation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define encapsulation in OOP.

A

Bundling data (attributes) & methods inside a class, hiding internal object state from outside.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why is encapsulation important?

A

Protects data, prevents direct access, enhances security and maintainability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a mutator method?

A

Setter method that modifies object attributes; usually void and takes parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an accessor method?

A

Getter method that returns attribute value without changing it; no parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Compare mutator and accessor methods.

A

Mutator changes attribute; accessor returns attribute value without changing it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is method overriding?

A

Subclass provides a new implementation for a method inherited from superclass with same signature.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is method overloading?

A

Multiple methods in the same class with same name but different parameter lists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Difference between method overriding and overloading?

A

Overriding: different classes, same method signature. Overloading: same class, same name, different parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does a minus sign (-) mean in class diagram fields?

A

Private access modifier.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does a hash sign (#) mean in class diagram fields?

A

Protected access modifier (package or subclass access).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How is a constant field represented in a class diagram?

A

All capital letters, underlined, with assigned value (e.g., MAXHOURS = 8).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly