0% found this document useful (0 votes)
7 views

OOP Study Guide

The document provides an overview of object-oriented programming concepts including the difference between objects and classes, encapsulation, inheritance, polymorphism, and UML diagrams. It also discusses advantages and disadvantages of OOP.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

OOP Study Guide

The document provides an overview of object-oriented programming concepts including the difference between objects and classes, encapsulation, inheritance, polymorphism, and UML diagrams. It also discusses advantages and disadvantages of OOP.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

COMP SCI STUDY GUIDE

D 1.1

- Difference between object and class -


A class is a blueprint with initial states and behaviors which objects are made
from.
An object is an instance of a class.

- What is declaration/instantiation/initialization?
Declaring a variable is giving it a name (identifier) and a data type
Instantiation is the creation of a new object using the keyword ‘new’
Initialization refers to the call to constructor

- The ‘main method’ class is called the driver class, only one exists per
project
D 1.2

- OOP takes up a lot of RAM space, so, it’s slower than procedural
- It takes up so much memory because everytime an object is instantiated,
space equivalent to the entire class is reserved for the object. Moreover,
each object has its own attributes and methods
D 1.3
- UML: unified modeling language
UML diagrams are a way to present classes, objects, and their relationship
without code
- Underlined: static, #: protected
- fieldName: type
- Getters rarely have parameters, setters usually do
- Associations are shown through lines/arrows
D 1.5
- Steps of problem solving:
Decompose problem into smaller parts (objects)
Understand relationships between the parts
- Importance of decomposition
Reducing complexity of problems so they’re easier to solve
D 1.6
- Dependency ‘uses’
- Aggregation ‘has a’
- Inheritance ‘is a’
- Association ‘uses’
- Multiplicity: a dependency of one to many
D 1.7
- Two classes are said to form a dependency if a change to one of them
necessitates a change in the other
- Dependencies are inevitable a lot of the time, having a lot of them is called
high-coupling. However, avoiding them as much as possible is best,
especially on large scale projects, because they create maintenance
overheads
- Maintenance overheads:
The changes need to be made to an entire system because of a change in one
component
- Encapsulation is one way to achieve decoupling
D 1.8
- Each primitive data type takes a certain amount of storage. It’s important to
choose the most appropriate data type for variables to not waste extra
space
- Parameters allow the passage of information or instructions into functions
and procedures
- They are the identifiers of the data used in a function/method
D 2.1 - D 2.4
- Encapsulation: the practice of making states private and only providing
access to said states through public behaviors
- This is done so that the data can’t be altered from outside a specific class
- 4 benefits:
Data hiding: the inner implementation of a class is unknown to all other parts of
the code. The inputs provided through setter methods and outputs received
through getters are the only things known
Flexibility
Reusability: write once, use many times, methods can be copied to different
classes with tweaks to meet new requirements
Testing: encapsulation allows for unit testing, which tests many different kinds of
data quickly. It’s easier to fix larger programs when the method producing the
wrong output is identified
- Polymorphism literally means many forms
As it pertains to programming, it means when 2 or more methods which have the
same name
- Two types of polymorphism are:
Overloading: two methods in the same class with different parameters
Overriding: two methods in different classes with the same parameters
- Advantages of inheritance
Minimizing the amount of duplicate code by only writing it once
Better organization and abstraction of code
More flexible to change
- Java libraries: time saving ex: sorting algorithms
- OOP disadvantages
Increased complexity for small problems, Unsuited to particular classes of
problems: involves more lines and is slower than procedural programming
- Team vs. Individual advantages
Faster completion because tasks are completed concurrently
Information hiding to reduce module dependencies (abstraction)
Allows experts to tackle what they specify in and use their skill sets optimally
D3
- Identifier: name given to a variable, method, class
- Instance variables: states of a parent class
- Local variable: can only be accessed inside their specific block of code
- A method is a set of code which has an identifier and can be called
(invoked)
- Accessor: getter
- Mutator: setter
- A constructor is a special method which is invoked when an object is
instantiated. They don’t have a return time and have the same name as
the class
- Procedures don’t return a value (void), functions return a value
- No method can return more than one value at a time
- Access modifiers (public, private, protected) dictate where a line of code
can be accessed from
- Protected: variables, methods, constructors with the access modifier
‘protected’ can only be accessed through the class it’s in and its
subclasses
- Static: if a variable method constructor etc in a parent class is static, it
changing will also change it in all the instances of that class

You might also like