Software Development Flashcards

1
Q

In OOP what is a class

A

A class is a template for an object and defines the state and behaviour of an object. The state is given by attributes which give an object’s properties. Behaviour is defined by the methods associated with a class, which describe the actions it can perform.

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

What is instantiation

A

The process of creating an object in OOP

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

What is a setter

A

A setter is a method that sets the value of a particular attribute.

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

What is a getter

A

A getter is another special method used in OOP which retrieves the value of a given attribute.

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

What is the purpose of using getter and setter methods

A

To make sure attributes cannot be directly accessed and edited by users. This property of object-oriented programming is called encapsulation.

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

What is a constructor method

A

A constructor allows a new object to be created, by defining the characteristics of the object

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

What is inheritance

A

Where a subclass inherits the attributes and methods of the superclass while having its own

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

Why is inheritance useful

A

Allows programmers to effectively reuse certain components and properties while making some changes.

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

What is meant by polymorphism

A

Objects can behave differently depending
on their class. This can result in the same method producing different outputs depending on the object involved.

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

Describe the 2 types of polymorphism

A

Overriding: redefining a method within a subclass and altering the code so that it
functions differently and produces a different output.

Overloading: passing in different parameters into a method

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

What is an advantage of polymorphism

A

Like inheritance, it allows for a high level of reusability, which makes it useful for projects were there are multiple components with similar properties

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

What is the advantage of encapsulation

A

Encapsulation is a key reason for choosing OOP as it makes the code more reliable by protecting attributes from being directly accessed. Code for different classes can also be produced independently of others.

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

Give 2 disadvantages of OOP

A

2 from:
- This is a different style of programming and so requires an alternative style of
thinking. This can be difficult for programmers accustomed to other paradigms to
pick up.
- OOP is not suited to all types of problems. Where few components are reused,
OOP may in fact result in a longer, more inefficient program.
- Generally unsuitable for smaller problems.

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