OOP Flashcards

1
Q

What are classes used for?

A

Blueprints or templates that can be used to create objects within OOP

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

What is an object?

A

A representation of a real world entity like a teacher,cat etc

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

What is instantiation?

A

Term used for creating an object from a class

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

What are methods?

A

Actions or behaviors that can be preformed

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

What is an identifier?

A

Name used to refer to an object

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

What is a function?

A

Method that must return a value

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

What is a procedure?

A

Method that doesn’t need to return a value

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

What is a constructor?

A

A special method within a class that is called automatically when an object is created

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

What do constructors define?

A

The initial values of instance variables and prepare objects for use

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

What is a public method?

A

They are accessible and can be invoked by any code within the same class or any external class

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

How do changes to a public method affect the rest of the code?

A

May have an impact on other parts of it so they should be carefully designed

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

When do we use public methods?

A

When you want to provide access to certain behaviors of an object or class to other parts of your program

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

What are private methods?

A

They are only accessible within the same class and cant be changed by external codes or classes

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

How do changes to a private method affect the rest of the code?

A

They have a localised impact since they are only used internally within the class providing flexibility to modify them without affecting the program

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

When do we use private methods?

A

When you have internal implementation details that should not be accessed by external code. Only meant to be used within the class itself for organising and managing code internally.

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

What is inheritance?

A

When a class inherits the methods and attributes of another class

17
Q

Why is inheritance good?

A

Promotes code reuse by allowing the derived class to inherit and utilise the existing code from base class
Avoids duplicating close and promotes better organisation and maintainability

18
Q

What is encapsulation?

A

The practice of grouping attributes and methods within a class

19
Q

Why is encapsulation good?

A

Ensures that data remains secure and is not accidently modified or misused by controlling access them by using modifiers(public,private)
Helps to organise code keeping related code within an object
Promotes code reusability

20
Q

Why does encapsulation use abstraction?

A

Reduces the complexity by hiding implementation details of a project making it easier to understand and work with

21
Q

What is polymorphism?

A

A concept in programming that allows objects to take on different forms or behaviors

22
Q

Why is polymorphism good?

A

Helps make code more flexible, reusable and easier to maintain

23
Q

What is overriding ?

A

Redefining a method within a subclass and altering the code so it functions differently and produces different output

24
Q

What is overloading?

A

Passing in different parameters into a method