OBJECT ORIENTED PROGRAMMING Flashcards
2 aspects of OOP
classes
objects
Class is
a template
the parent
Object is
an instance of a class the child
Objects inherit
class methods class variables
Create a Class
Use Class keyword
Create an Object
specify Class name
followed by Object name
= ‘new’ keyword
Class Members are
fields & methods inside an object
use (.) syntax to create an object of the class
myObj.color
Multiple Classes for
Good organisation
fields
methods
execution
Access Modifier is
public keyword
makes fields of one Class accessible for other classes
Constructor is
special method
initializes objects
Constructor used
called when an object of a class is created
Constructor advantages
save time
efficient
Access Modifiers
set access level and visibility for classes fields methods properties
Public
all classes access
Private
code only accessible within the same class
Protected
code accessible within same or inherited class
Internal
code accessible within its own assembly
Encapsulation is
ensures sensitive data is hidden
Encapsulation how
Properties
declare fields/variables private
provide public, get, set, methods
Properties do
access private variables outside of a private class Uses get & set methods for this
Abstraction is
hiding certain details from user
a restricted class
Abstract method
only used in Abstract class uses body of derived class -that it inherited from
Override is
keyword that overrides the base class method
Encapsulation is
an object’s ability to hide data and behaviour
Encapsulation does
enables a group of properties, methods, fields to be considered a single unit