Module definitions Flashcards

(57 cards)

1
Q

What is an OO language

A

A language which promotes or allows object oriented programming and design

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

What is an object?

A

A collection of data

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

What is a class?

A

Defines what an object can do

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

What is a class method?

A

A static method which is associated with a class

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

What is an instance method?

A

A non-static method which is associated with an object

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

What is aggregation?

A

An object within an object where the inner object has a lifetime of its own

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

What is the symbol for aggregation in a class diagram?

A

An empty diamond

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

What is composition?

A

An object within object where the inner object lasts as long as the outer object

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

What is the symbol for composition in class diagram?

A

A black filled in diamond

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

What is abstraction?

A

Hides the implementation from the user for simplicity

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

What is an abstract method?

A

A method without implementation (no {}) - these are placeholders for sub-classes to implement/override

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

What is an abstract class?

A

A class with at least one abstract method- CANNOT create instances of the class (only references)

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

What is an interface?

A

A class where every method is abstract and any data is static and final. (a class with no implementation)

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

What is inheritance?

A

A class is as specialisation of another class

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

What is the symbol for inheritance in a class diagram?

A

A white arrow

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

How does inheritance work with classes?

A

A class extends a class

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

How does inheritance work with a class and an interfaces?

A

A class implements an interface

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

How does inheritance work with interfaces?

A

An interface extends an interface

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

How does inheritance work with interfaces and classes?

A

DOESNT WORK THIS WAY -> a class can implement an interface not the other way round

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

What is parametric polymorphism?

A

Code which works with multiple different types

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

What is type erasure?

A

Type exists only at compile time and are erased before runtime

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

What is ad-hoc polymorphism

A

Function overloading -> same function name but multiple different versions depending on the parameter types

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

What is sub-type polymorphism?

A

Sub-classing (polymorphism in OO terms)

24
Q

What is runtime polymorphism?

A

Compiler does not know the type but looks it up at runtime

25
What does it mean if a variable is final?
It is unchangeable (cant be changed in any implementations or extensions, both methods and classes can be final -can't change implementation or can't subclass)
26
What is a design pattern?
A reusable solution to commonly faced problems
27
What is a model-view-controller?
Separates data storage, presentation to user and control logic
28
What is a behavioural pattern?
Patterns that change the behaviour of an object
29
What is a strategy pattern?
Lets another object modify the behaviour of an object
30
What is an example of a strategy pattern?
Layout manager
31
What is an observer pattern?
Tell me when something happens
32
What is an example of an observer pattern?
Button
33
What is an iterative pattern?
Lets you iterate through contents
34
What is an example of an iterative pattern?
For each loop! Mainclass implements class iterable, now we can have a myIterator class which implements iterator
35
What is an iterable?
A container to iterate through
36
What is an iterator?
Object to do the iteration
37
What is a creational pattern?
Pattern related to the creation of objects
37
What is a singleton?
Creates just one instance of an object and use it anywhere
38
What is an example of a singleton
To create a constant object
39
What is a simple factory?
Creates lots of instances of object
40
What is boxing?
Wrapping up a data type in an object
41
What is unboxing?
Extracting the data type again after boxing it up
42
What is auto-boxing?
The process of wrapping a data type in an object then extracting the data type again
43
What is an anonymous class?
An inner class without a name
44
What is a lambda?
A simpler case for an anonymous class. When an inner class without a name implements an interface with one method
45
What is a constructor?
Methods which are called to initialise new objects -> same name as the class like public main()
46
What is encapsulation?
Grouping together methods and data in a class
47
Who can view a public method?
Anyone
48
Who can view a protected method?
Anything in this package and subclasses
49
Who can view a package method?
Anything in this package
50
Who can view a private method?
Only this class can access it
51
What are the limitations of parametric polymorphism?
- Type erasure - Can only parametrise on a sub-class of a specific type
52
How do we change something from type a to a generic type?
- Replace all of the data type with OBJECT - Except when we are having a parameter of type T - If a method returns a type T, type cast it before returning
53
What are the two types of pattern we have?
- Behavioural patterns - Creational patterns
54
Give examples of behavioural patterns
Observer, Strategy and Iterator
55
Give examples of creational strategy patterns
Singleton and simple factory
56
Why are design patterns useful in general?
- Simplify coding process - Enhance code maintainability - Promote code reuse