Comp Prog Reviewer
Comp Prog Reviewer
Week 11
OOP – Stands for Object Oriented Programming.
Types of Programming Style
1. Procedural Programming - It is about writing procedures or functions that perform
operations on the data. Example: C , Cobol, Pascal
2. OOP- It is about creating objects that contain both data(variables) and
functions(methods).
Fundamentals of OOP
1. Class - is a template or blueprint from which objects are created
- States=Instance Variables
- Behaviors=Instance Methods
- Instance Variables=Member Variable
Importance or Benefits of class
a. Think or recall the different primitive or basic data types.
b. Have all the control of its properties and behavior.
c. This is where creating a your own class.
2. Non-Access Modifiers - do not control access level, but provides other functionality
a. Static- Class methods and variables
b. Final- Finalizing implementation
c. Abstract – Abstract Classes
d. Synchronized & Volatile- Threads
Package - be defined as a grouping of related types.
Purpose of creating package
1. Avoid naming conflicts
2. Write maintainable code
3. More control access
4. To make searching easier
Categories of Packages
1. Built-in Packages
a. Java.lang
b. Java.io
2. User-defined Packages
a. Java API - prewritten classes, that are free to use
- Divided into classes and packages
Week 13
Inheritance – defined as the process where one class acquires the properties.
Two categories
1. Subclass – inherits another class
2. Superclass
inheritance and polymorphism are used together in java to achieve fast performance and
readability of code.
Types of Inheritance
1. Single Inheritance
2. Multilevel Inheritance
3. Hierarchical Inheritance
4. Multiple Inheritance
5. Hybrid Inheritance
Polymorphism - is the ability of an entity to take several forms; means “many forms”
Two types:
1. Compile time Polymorphism
- It is also known as Static Polymorphism
- Function overloading
- Method Overloading: multiple functions with same name but different
parameter.
2. Runtime Polymorphism
- It is also known as Dynamic Method Dispatch
- Method overriding - a derived class has a definition for one of the member
functions.