OOP Flashcards
What are constructors?
They are a special kind of method that plays the role of initializing objects?
Constructors vs methods
Constructors: Initialize and object’s state
Methods: Used to exhibit functionality of an object.
What are their 3 peculiarities(constructors)
They have the same name as the class itself They do not have a return type -- not even void Invoked using the new operator when an object is created
Method overloading
Multiple methods can have the same name with different paramters.
Instance vs Static class members
Static: Can be invoked directly from their class
Adv of OOP
Modularization
Encapsulation
Understandability
Maintenance
Public vs Private
Public: Access modifier visible to all classes in any package
Private: Access modifier visible only to declared class.
Objects
An object is an entity in the real world. An object has:
A unique identity,
state(Also known as properties or attributes)
behaviour(Methods): What the object can do.
Classes
Objects of the same type are defined using a common class A class is a template or blueprint that defines the properties and behaviours for objects.
What does a class use
Variables to define the state
methods to define behaviors
Constructors to perform initializing actions
Access modifiers
Used for controlling levels of access class members in Java