OOP Flashcards
class
template of blueprint from which objects are created and receive their states(properties/fields) and behaviour(methods)
static
class method
belongs to class
don’t need an instance to use it
underline
non static
instance method
belongs to object
need that instance to call it
void
method doesn’t return anything
object
an instance of a class
there can be multiple instances of a class in a program.
contains both the data and the function, which operates on the data.
has its own unique properties(data) and each method can be called on each object.
abstraction
displaying only essential information and hiding the details.
creating new data types suited for a specific application (that the programming language does not know about.)
encapsulation
hiding the code and data into a single unit/method/class (protect inner workings of an object)
makes use of information hiding (make properties private - use methods to access them.)
functionality + data of object organised into a single structure by concealing the implementation of the object. done by declaringdata types as private
information hiding
inner workings of a class being hidden from the class user
use access modifier private (in order to have encapsulation)
difference between abstraction and encapsulation
Abstraction hides details at the design level (complexity) , while Encapsulation hides details at the implementation level (inner workings).
public
Accessible everywhere
can be accessed by the class.it is declared in and by by any other class
+
private
-
Accessible only in its own class
protected
Accessible by class and any subclass (in any package) and by any other class in the same package
inheritance
one object acquires the properties and behaviours of the parent object (along w having their own unique attributes)
key word- extends use clear arrow
parent- child relationship between superclass + subclass
suitable when 2 classes have many fields + methods in common
default constructor
constructor w/ no parameters
sets attributes of the object to default values
polymorphism
ability of a variable/object or method to take on multiple forms based on its current situation
overriding + overloading
variables
Fields/Attributes/Characteristics/Properties
describe the objects properties
store data for processing.
given a name (identifier), are of a specific type and have a value assigned to it.
all take up a different amount of size + has a unique address
local variables
declared inside methods
do not exist when method is finished, cannot be used outside of method
used instead of global- space in RAM not wasted
Different methods can have local variables with the same names because the methods cannot see
each other’s local variables.
global variables
declared in class above all methods
scope is inside the entire program
can be used by all methods