Mod1 Ppt1-Chap 1
Mod1 Ppt1-Chap 1
AN OVERVIEW OF JAVA
OOP(Object Oriented Programming)
• Object oriented programming (OOP) is the core of
Java programming.
• While object-oriented programming is about
creating objects that contain both data and
methods.
• Java is a general purpose, object- oriented
programming language developed by Sun
Microsystems.
• It was invented by James Gosling and his team and
was initially called as Oak.
Two Paradigms:
• Every program contains 2 components code and data.
• Two approaches are there to solve the problem and in
program writing: Procedure oriented and object
oriented.
Procedure Oriented:
• Procedure oriented programs are written based on
―whats happening‖ around, where the code acts on
data. Ex: C etc
Object Oriented:
• Object oriented programs are written based on ―Who
is being affected‖ around, which manages the
increasing complexity.
• Ex: C++, JAVA, Small Talk etc
• C
Class a{
Printf(“Welcome”); // Procedure Oriented:
}
• C++
Class a{
Cout<<welcome; //Object Oriented:
}
The Three OOP:
The three important features of OOP are:
• Encapsulation
• Inheritence
• Polymorphism
Encapsulation
• It is a process of wrapping up the data
members along with related data handlers
method is called Encapsulation.
• Wrapping up the data members and data
handlers method means we are grouping both
as a single unit. In Java, we group or wrap
both inside the Class, so Class is a single unit
that consists of data members as well as
methods.
Ex
Ex
Note:
This keyword
• this can be used to refer current class instance variable.
• this can be used to invoke current class method
(implicitly)
• this() can be used to invoke current class constructor.
• this can be passed as an argument in the method call.
• this can be passed as argument in the constructor call.
• this can be used to return the current class instance
from the method.
Inheritence:
• Inheritence is the process by which one object
acquires the properties of another object. This
is important as it supports the concept of
hierarchical classification.
• By the use of inheritence, sub class derived
from the parent class or base class.
• Ex: A child inheriting properties from parents