Object oriented programming Flashcards

1
Q

Define class

A

The definition of the attributes and methods of a group of similar objects

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

Define attributes

A

The properties that an object if that type has, implemented using variables

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

Define methods

A

Processes or actions that an object of that type can do, implemented with subroutines

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

Define object

A

A specific instance of a class

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

Define instantiation

A

The process of creating an object based in its class definition

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

What is a constructor

A

A special method that is called when the object is instantiated

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

What is the relationship between an object and its class?

A

An object is an instance of the class

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

What is encapsulation?

A

The concept of grouping similar attributes, data and methods together in one object

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

What is information hiding?

A

Controlling access to other data stored within an object

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

State the name, symbol and meaning for the three main access specifiers

A
  • Private: Cannot be accessed from any other object
    + Public: Can be accessed from any object
    # Protected: Can only be accessed from this object or an object of this class/ subclass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is grouped together in encapsulation?

A

Attributes
Methods
Data

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

What are the advantages of encapsulation?

A

Makes program more modular
Makes debugging easier
Allows programming tasks to be split between different programmers
Prevents access to certain attributes or methods from other objects

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

How is it possible for private attributes to be accessed by other objects?

A

Getters and setters which are public methods that can access private attributes

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

What is inheritance?

A

The idea that a class can use the attributes and methods defined in another class

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

What is a subclass?

A

A class that inherits the attributes and methods from another class

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

What is a base/parent class?

A

A class whose attributes and methods are inherited by another class

17
Q

What are the benefits of inheritance?

A

Same code can be reused without the need to copy it
If code needs changing it only needs to be changed in the base class
Less chance of errors
Easier to debug

18
Q

What is aggregation?

A

The idea that one class can be related to another using a ‘has a’ relationship

19
Q

What is a container class?

A

A class or object that contains or is made up of other objects

20
Q

Describe the two types of aggregation

A

Association aggregation: Aggregation where the container object can be destroyed without destroying it’s associated objects

Inheritance aggregation: Aggregation where, if the container object is destroyed then all associated objects are destroyed

21
Q

What is an associated class/object?

A

A class/object that is used to make up another object

22
Q

What is the difference between inheritance and aggregation?

A

Inheritance is an ‘is a’ relationship, aggregation is a has a relationship

23
Q

Define polymorphism

A

The ability for two methods with the same name to carry out their actions using different code

24
Q

Define overriding

A

A method in a subclass re-defining a method inherited from a bass class

25
Q

How can a computer identify which method to run if there are two methods with identical identifiers in that class?

A

Comparing the number and type of the arguments

against the expected parameters of each method

26
Q

What is an interface?

A

A collection of subroutines that can be implemented by unrelated classes

27
Q

What are the advantages of using OOP?

A

OOP more closely resembles the real world relationships between objects
Easier to debug
Classes can be reused in other code
Code can be reused through inheritance and aggregation

28
Q

What are abstract methods?

A

A method that has no program code and is intended to be overwritten

29
Q

What are virtual methods?

A

Methods that may be overwritten (default in some languages)

30
Q

What are static methods?

A

Methods in a class that can be called without the need to create an object of that class

31
Q

What should be included in a detailed class diagram?

A
Class names
Attributes
Methods
Data types
Access specifiers
Relationships