01 - Intro to OOP Flashcards

1
Q

What is the definition of an object in Object Oriented Programming?

A

An object is a ‘thing’ that has an abstract identity, with two components: data and actions.

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

What are the components of an object?

A

Objects have states (variables) and behaviours (methods).

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

What is a class in Object Oriented Programming?

A

A class can be defined as a template/blueprint that describes the behaviours/states that objects of its type support.

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

In software, how are states and behaviours represented?

A

States are stored in fields and behaviours are shown in methods.

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

What is a constructor?

A

Every class has a constructor, which is invoked each time a new object is created.

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

What is the main rule regarding constructors?

A

1) A special method used to initialize objects of a class.
2) It is called automatically when an object of the class is created.
3) The purpose of the constructor is to set up the initial state of an object, typically by assigning values to the instance variables or performing setup tasks.

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

What are the three steps in object creation?

A

1) Declaration
2) Instantiation
3) Initialization

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

What keyword is used to create new objects in Java?

A

The ‘new’ keyword.

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

What is the difference between a class and an object?

A

A class is a template, while an object is an instance of that class.

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

True or False: Instantiating objects uses RAM.

A

True.

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

What is a potential downside of instantiating many objects?

A

A lot of RAM can be wasted if many objects are reserved but not used.

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

What is a good idea for memory management in object creation?

A

Creating a linked list (dynamic data type) of objects.

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

What is a bad idea for memory management in object creation?

A

Creating an array (static data type) of objects.

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

Fill in the blank: An object is created from a _______.

A

[class]

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

What are the key terms associated with Object Oriented Programming?

A

1) Object
2) Class
4) State
4) Behaviour
5) Field
6) Method
7) Constructor
8) Declaration
9) Instantiation
10) Initialization

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

What does the ‘new’ keyword do in object creation?

A

It is used to create the object.

17
Q

What is the output when creating a new Puppy object with the name ‘Tommy’?

A

Passed Name is Tommy

18
Q

What are fields in the context of an object?

A

Fields are similar to local variables, but are not declared inside any method.