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

Comp Prog Reviewer

Uploaded by

smurf.riotacc
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Comp Prog Reviewer

Uploaded by

smurf.riotacc
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

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).

Advantages of OOP than Procedural Programming


1. Faster and easier to execute.
2. Provides clear structure
3. Makes Java “DRY”(Don’t Repeat Yourself) and helps debug
4. Creates Full reusable applications

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. Object - considered as an instance of a particular class.


- is an entity that has states (variables) and behaviors (methods)
Two characteristics of Objects
1. State - refers to status or properties of the object.
2. Behavior - refers to actions that it takes or what it does.

Variable such as x are also called attribute or field


C
Week 12

Constructor - Special Method


- is called when an object of a class is created.
- Has same name as the class name.
- it constructs the values at the time of object creation
Rules for creating Java constructor

1. Same as its class name


2. Must have no explicit return type
3. Cannot be abstract, static, final, and synchronized
Access Modifiers- Declaring constructors; Determines accessibility of scope of the constructor
Two Types of Java Constructors.
1. Default constructor/ no argument - does not accept any parameters instead, using these
constructors the instance variables of a method
2. Parameterized constructor/ With parameter Constructors
This - refers to the current object in a method or constructor ; to eliminate the confusion between
class attributes and parameters
Modifiers- are keywords that you add to those definitions to change their meanings.
Two Groups of Modifiers
1. Access Modifiers- controls the access level or scope
a. Default- Visible to package
b. Private- Visible to class
c. Public- Visible to all classes
d. Protected- Visible to the package and all subclasses

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.

You might also like