01 - Intro to OOP Flashcards
What is the definition of an object in Object Oriented Programming?
An object is a ‘thing’ that has an abstract identity, with two components: data and actions.
What are the components of an object?
Objects have states (variables) and behaviours (methods).
What is a class in Object Oriented Programming?
A class can be defined as a template/blueprint that describes the behaviours/states that objects of its type support.
In software, how are states and behaviours represented?
States are stored in fields and behaviours are shown in methods.
What is a constructor?
Every class has a constructor, which is invoked each time a new object is created.
What is the main rule regarding constructors?
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.
What are the three steps in object creation?
1) Declaration
2) Instantiation
3) Initialization
What keyword is used to create new objects in Java?
The ‘new’ keyword.
What is the difference between a class and an object?
A class is a template, while an object is an instance of that class.
True or False: Instantiating objects uses RAM.
True.
What is a potential downside of instantiating many objects?
A lot of RAM can be wasted if many objects are reserved but not used.
What is a good idea for memory management in object creation?
Creating a linked list (dynamic data type) of objects.
What is a bad idea for memory management in object creation?
Creating an array (static data type) of objects.
Fill in the blank: An object is created from a _______.
[class]
What are the key terms associated with Object Oriented Programming?
1) Object
2) Class
4) State
4) Behaviour
5) Field
6) Method
7) Constructor
8) Declaration
9) Instantiation
10) Initialization