SlideShare une entreprise Scribd logo
1  sur  28
PRESENTATION SUBMIT TO
Saiful islam(16339202030)
Hamida Sultana
Ilias Ahmed(16339202142)
Submit To:
Tanjea Anne
Lecturer of cse dept.
Peoples university of bangladesh
Object-oriented programming System(OOPs) is a programming
paradigm based on the concept of “objects” that contain data and
methods. The primary purpose of object-oriented programming is to
increase the flexibility and maintainability of programs. Object
oriented programming brings together data and its
behaviour(methods) in a single location(object) makes it easier to
understand how a program works. We will cover each and every
feature of OOPs in detail so that you won’t face any difficultly
understanding OOPs Concepts.
OOPs Concepts – Table of Contents
What is an Object
What is a class
Constructor in Java
Object Oriented Programming Features
Abstraction
Encapsulation
Inheritance
What is an Object
Object: is a bundle of data and its behavior(often known as
methods).
Objects have two characteristics: They
have states and behaviors.
Examples of states and behaviors
Example 1:
Object: House
State: Address, Color, Area
Behavior: Open door, close door
class House {
String address;
String color;
double are;
void openDoor() {
//Write code here }
void closeDoor()
{ //Write code here } ...
}
method
object properties
Example 2 :
Let’s take another example.
Object: Car
State: Color, Brand, Weight, Model
Behavior: Break, Accelerate, Slow Down, Gear
change.
the states and behaviors of an object, can be
represented by variables and methods in the
class respectively.
What is a Class in OOPs Concepts
A class can be considered as a blueprint using which you can create as many objects as you like.
For example, here we have a class Website that has two data members (also known as fields,
instance variables and object states). This is just a blueprint, it does not represent any website,
however using this we can create Website objects (or instances) that represents the websites. We
have created two objects, while creating objects we provided separate properties to the objects using
constructor.
public class Website {
String webName;
int webAge;
Website(String name, int age)
{ this.webName = name;
this.webAge = age; }
public static void main(String args[]){
//Creating objects
Website obj1 = new Website(“ilias.com", 5);
Website obj2 = new Website("google.com", 18);
//Accessing object data through reference
System.out.println(obj1.webName+" "+obj1.webAge);
System.out.println(obj2.webName+" "+obj2.webAge); } }
What is a Constructor
Constructor looks like a method but it is in fact not a
method. It’s name is same as class name and it does not
return any value. You must have seen this statement in
almost all the programs I have shared above:
MyClass obj = new MyClass();
If you look at the right side of this statement, we are calling
the default constructor of class myClassto create a new
object (or instance).
Example of constructor
public class ConstructorExample {
int age;
String name; //Default constructor
ConstructorExample()
{ this.name=“ilias";
this.age=40; } //Parameterized constructor
ConstructorExample(String n,int a)
{ this.name=n; this.age=a; }
public static void main(String args[]){
ConstructorExample obj1 = new ConstructorExample();
ConstructorExample obj2 = new ConstructorExample("Saiful", 26);
System.out.println(obj1.name+" "+obj1.age);
System.out.println(obj2.name+" "+obj2.age); } }
Abstraction
One of the most fundamental concept of OOPs is Abstraction. Abstraction
is a process where you show only “relevant” data and “hide” unnecessary
details of an object from the user. For example, when you login to your
Amazon account online, you enter your user_id and password and press
login, what happens when you press login, how the input data sent to
amazon server, how it gets verified is all abstracted away from the you.
Another example of abstraction: A car in itself is a well-defined object,
which is composed of several other smaller objects like a gearing system,
steering mechanism, engine, which are again have their own subsystems.
But for humans car is a one single object, which can be managed by the
help of its subsystems, even if their inner details are unknown.
public abstract class Employee {
private String name;
private String address;
private int number;
public Employee(String name, String address, int number) {
System.out.println("Constructing an Employee");
this.name = name;
this.address = address;
this.number = number; }
public double computePay() {
System.out.println("Inside Employee computePay");
return 0.0; }
public void mailCheck() { System.out.println("Mailing a check to " + this.name + " " +
this.address); }
public String toString() { return name + " " + address + " " + number; } public String
getName() { return name; } public String getAddress() { return address; } public void
setAddress(String newAddress) { address = newAddress; }
public int getNumber() { return number; } }
What is encapsulation?
The whole idea behind encapsulation is to hide the implementation details
from users. If a data member is private it means it can only be accessed
within the same class. No outside class can access private data member
(variable) of other class.
However if we setup public getter and setter methods to update (for
example void setSSN(int ssn))and read (for example int getSSN()) the
private data fields then the outside class can access those private data
fields via public methods.
class EncapsulationDemo{
private int ssn;
private String empName;
private int empAge;
//Getter and Setter methods
public int getEmpSSN(){ return ssn; }
public String getEmpName(){ return empName; }
public int getEmpAge(){ return empAge; }
public void setEmpAge(int newValue){ empAge =
newValue; } public void setEmpName(String newValue){
empName = newValue; }
public void setEmpSSN(int newValue){ ssn = newValue; }
} public class EncapsTest{
public static void main(String args[]){
EncapsulationDemo obj = new EncapsulationDemo();
obj.setEmpName(“ilias"); obj.setEmpAge(38);
obj.setEmpSSN(112242); System.out.println("Employee
Name: " + obj.getEmpName());
System.out.println("Employee SSN: " +
obj.getEmpSSN()); System.out.println("Employee Age: "
+ obj.getEmpAge()); } }
The process by which one class acquires the properties(data members) and
functionalities(methods) of another class is called inheritance. The aim of inheritance
is to provide the reusability of code so that a class has to write only the unique
features and rest of the common properties and functionalities can be extended from
the another class.
Child Class:
The class that extends the features of another class is known as child class, sub class
or derived class.
Parent Class:
The class whose properties and functionalities are used(inherited) by another class is
known as parent class, super class or Base class.
Inheritance is a process of defining a new class based on an existing class by
extending its common data members and methods.
Inheritance allows us to reuse of code, it improves reusability in your java application.
Note: The biggest advantage of Inheritance is that the code that is already present in
base class need not be rewritten in the child class.
Syntax: Inheritance in Java
To inherit a class we use extends keyword. Here class XYZ is child class and class
ABC is parent class. The class XYZ is inheriting the properties and methods of ABC
class.
class XYZ extends ABC { }
Inheritance Example
class Teacher {
String designation = "Teacher";
String collegeName = “pub";
void does(){ System.out.println("Teaching"); } }
public class PhysicsTeacher extends Teacher{
String mainSubject = "Physics";
public static void main(String args[]){
PhysicsTeacher obj = new PhysicsTeacher();
System.out.println(obj.collegeName);
System.out.println(obj.designation);
System.out.println(obj.mainSubject);
obj.does(); } }
Types of inheritance
To learn types of inheritance in detail, refer:
Types of Inheritance in Java.
Single Inheritance: refers to a child and parent class relationship where a class extends the another class.
Polymorphism
This post provides the theoretical explanation of polymorphism with
real-life examples. For detailed explanation on this topic with java
programs refer polymorphism in java and runtime & compile time
polymorphism.
Polymorphism means to process objects differently based on their
data type.
In other words it means, one method with multiple implementation,
for a certain class of action. And which implementation to be used is
decided at runtime depending upon the situation (i.e., data type of
the object)
This can be implemented by designing a generic interface, which
provides generic methods for a certain class of action and there can
be multiple classes, which provides the implementation of these
generic methods.
Polymorphism could be static and dynamic both. Method Overloading is
static polymorphism while, Method overriding is dynamic polymorphism.
Overloading in simple words means more than one method having the
same method name that behaves differently based on the arguments
passed while calling the method. This called static because, which method
to be invoked is decided at the time of compilation
Overriding means a derived class is implementing a method of its super
class. The call to overriden method is resolved at runtime, thus called
runtime polymorphism
Types of polymorphism in java- Runtime and Compile time
polymorphism
types of polymorphism. There are two types of polymorphism in
java:
1) Static Polymorphism also known as compile time
polymorphism
2) Dynamic Polymorphism also known as runtime polymorphism
Compile time Polymorphism (or Static polymorphism)
Polymorphism that is resolved during compiler time is known as
static polymorphism. Method overloading is an example of
compile time polymorphism.
Method Overloading: This allows us to have more than one
method having the same name, if the parameters of methods are
different in number, sequence and data types of parameters. We
have already discussed Method overloading here: If you didn’t
read that guide, refer: Method Overloading in Java
Example of static Polymorphism
class SimpleCalculator {
int add(int a, int b) { return a+b; }
int add(int a, int b, int c) { return a+b+c; } }
public class Demo { public static void main(String
args[]) {
SimpleCalculator obj = new SimpleCalculator();
System.out.println(obj.add(10, 20));
System.out.println(obj.add(10, 20, 30)); } }
Output: 30 60
Runtime Polymorphism (or Dynamic polymorphism)
Dynamic polymorphism is a process in which a call to an
overridden method is resolved at runtime, thats why it is
called runtime polymorphism. I have already discussed
method overriding in detail in a separate tutorial, refer
it: Method Overriding in Java.
Example
In this example we have two classes ABC and
XYZ. ABC is a parent class and XYZ is a child
class. The child class is overriding the method
myMethod() of parent class.
class ABC{
public void myMethod(){
System.out.println("Overridden Method"); }
}
public class XYZ extends ABC{
public void myMethod(){
System.out.println("Overriding Method"); }
public static void main(String args[]){
ABC obj = new XYZ(); obj.myMethod(); } }
Design by ilias
Oop features java presentationshow

Contenu connexe

Tendances

Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classesFajar Baskoro
 
The Ring programming language version 1.5.2 book - Part 70 of 181
The Ring programming language version 1.5.2 book - Part 70 of 181The Ring programming language version 1.5.2 book - Part 70 of 181
The Ring programming language version 1.5.2 book - Part 70 of 181Mahmoud Samir Fayed
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Javabackdoor
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object ReferencesTareq Hasan
 
Java căn bản - Chapter2
Java căn bản - Chapter2Java căn bản - Chapter2
Java căn bản - Chapter2Vince Vo
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHPMichael Peacock
 
Object oriented design
Object oriented designObject oriented design
Object oriented designlykado0dles
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectOUM SAOKOSAL
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in javaAtul Sehdev
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in javaMahmoud Ali
 
The Ring programming language version 1.4.1 book - Part 20 of 31
The Ring programming language version 1.4.1 book - Part 20 of 31The Ring programming language version 1.4.1 book - Part 20 of 31
The Ring programming language version 1.4.1 book - Part 20 of 31Mahmoud Samir Fayed
 
Lecture 4_Java Method-constructor_imp_keywords
Lecture   4_Java Method-constructor_imp_keywordsLecture   4_Java Method-constructor_imp_keywords
Lecture 4_Java Method-constructor_imp_keywordsmanish kumar
 
The Ring programming language version 1.9 book - Part 84 of 210
The Ring programming language version 1.9 book - Part 84 of 210The Ring programming language version 1.9 book - Part 84 of 210
The Ring programming language version 1.9 book - Part 84 of 210Mahmoud Samir Fayed
 

Tendances (20)

Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classes
 
The Ring programming language version 1.5.2 book - Part 70 of 181
The Ring programming language version 1.5.2 book - Part 70 of 181The Ring programming language version 1.5.2 book - Part 70 of 181
The Ring programming language version 1.5.2 book - Part 70 of 181
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
 
Only oop
Only oopOnly oop
Only oop
 
Oop
OopOop
Oop
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
 
Java căn bản - Chapter2
Java căn bản - Chapter2Java căn bản - Chapter2
Java căn bản - Chapter2
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHP
 
Introduction to c ++ part -2
Introduction to c ++   part -2Introduction to c ++   part -2
Introduction to c ++ part -2
 
Object oriented design
Object oriented designObject oriented design
Object oriented design
 
L03 Software Design
L03 Software DesignL03 Software Design
L03 Software Design
 
Java basic
Java basicJava basic
Java basic
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and Object
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
 
Core java complete notes - Contact at +91-814-614-5674
Core java complete notes - Contact at +91-814-614-5674Core java complete notes - Contact at +91-814-614-5674
Core java complete notes - Contact at +91-814-614-5674
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in java
 
The Ring programming language version 1.4.1 book - Part 20 of 31
The Ring programming language version 1.4.1 book - Part 20 of 31The Ring programming language version 1.4.1 book - Part 20 of 31
The Ring programming language version 1.4.1 book - Part 20 of 31
 
Lecture 7 arrays
Lecture   7 arraysLecture   7 arrays
Lecture 7 arrays
 
Lecture 4_Java Method-constructor_imp_keywords
Lecture   4_Java Method-constructor_imp_keywordsLecture   4_Java Method-constructor_imp_keywords
Lecture 4_Java Method-constructor_imp_keywords
 
The Ring programming language version 1.9 book - Part 84 of 210
The Ring programming language version 1.9 book - Part 84 of 210The Ring programming language version 1.9 book - Part 84 of 210
The Ring programming language version 1.9 book - Part 84 of 210
 

Similaire à Oop features java presentationshow

oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfacesmadhavi patil
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsMaryo Manjaruni
 
Chapter 5 (OOP Principles).ppt
Chapter 5 (OOP Principles).pptChapter 5 (OOP Principles).ppt
Chapter 5 (OOP Principles).ppthenokmetaferia1
 
Basic concept of class, method , command line-argument
Basic concept of class, method , command line-argumentBasic concept of class, method , command line-argument
Basic concept of class, method , command line-argumentSuresh Mohta
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slotsmha4
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slotsmha4
 
Ch.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsCh.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsITNet
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...Sagar Verma
 
Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascriptUsman Mehmood
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptxRaazIndia
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxKunalYadav65140
 

Similaire à Oop features java presentationshow (20)

oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
 
My c++
My c++My c++
My c++
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
Chapter 5 (OOP Principles).ppt
Chapter 5 (OOP Principles).pptChapter 5 (OOP Principles).ppt
Chapter 5 (OOP Principles).ppt
 
Basic concept of class, method , command line-argument
Basic concept of class, method , command line-argumentBasic concept of class, method , command line-argument
Basic concept of class, method , command line-argument
 
Ch-2ppt.pptx
Ch-2ppt.pptxCh-2ppt.pptx
Ch-2ppt.pptx
 
Oops
OopsOops
Oops
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
 
11.Object Oriented Programming.pdf
11.Object Oriented Programming.pdf11.Object Oriented Programming.pdf
11.Object Oriented Programming.pdf
 
Ch.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsCh.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objects
 
Oop java
Oop javaOop java
Oop java
 
Basics of oops concept
Basics of oops conceptBasics of oops concept
Basics of oops concept
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
 
Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascript
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
 

Plus de ilias ahmed

We need parallel or series connections of n mos and pmos with a nmos source t...
We need parallel or series connections of n mos and pmos with a nmos source t...We need parallel or series connections of n mos and pmos with a nmos source t...
We need parallel or series connections of n mos and pmos with a nmos source t...ilias ahmed
 
Android development-tutorial
Android development-tutorialAndroid development-tutorial
Android development-tutorialilias ahmed
 
Signle assignmentforbciit
Signle assignmentforbciitSignle assignmentforbciit
Signle assignmentforbciitilias ahmed
 
Compiler design lab
Compiler design labCompiler design lab
Compiler design labilias ahmed
 
artificial intelligence
artificial intelligence artificial intelligence
artificial intelligence ilias ahmed
 
Compiler designs presentation final
Compiler designs presentation  finalCompiler designs presentation  final
Compiler designs presentation finalilias ahmed
 
Compiler designs presentation by group 2 final final
Compiler designs presentation by group 2 final finalCompiler designs presentation by group 2 final final
Compiler designs presentation by group 2 final finalilias ahmed
 
Assmemble langauge for slideshare.net
Assmemble langauge for slideshare.netAssmemble langauge for slideshare.net
Assmemble langauge for slideshare.netilias ahmed
 
Phpfundamnetalfromtutplus
PhpfundamnetalfromtutplusPhpfundamnetalfromtutplus
Phpfundamnetalfromtutplusilias ahmed
 
Assignment complier design (GROUP1)
Assignment complier design (GROUP1)Assignment complier design (GROUP1)
Assignment complier design (GROUP1)ilias ahmed
 
Lisp programming
Lisp programmingLisp programming
Lisp programmingilias ahmed
 
Lispprograaming excercise
Lispprograaming excerciseLispprograaming excercise
Lispprograaming excerciseilias ahmed
 
Assembly lab up to 6 up (1)
Assembly lab up to 6 up (1)Assembly lab up to 6 up (1)
Assembly lab up to 6 up (1)ilias ahmed
 
Data communications
Data communicationsData communications
Data communicationsilias ahmed
 
Microprocessor projec ts
Microprocessor projec tsMicroprocessor projec ts
Microprocessor projec tsilias ahmed
 

Plus de ilias ahmed (20)

We need parallel or series connections of n mos and pmos with a nmos source t...
We need parallel or series connections of n mos and pmos with a nmos source t...We need parallel or series connections of n mos and pmos with a nmos source t...
We need parallel or series connections of n mos and pmos with a nmos source t...
 
Android development-tutorial
Android development-tutorialAndroid development-tutorial
Android development-tutorial
 
Signle assignmentforbciit
Signle assignmentforbciitSignle assignmentforbciit
Signle assignmentforbciit
 
Compiler design lab
Compiler design labCompiler design lab
Compiler design lab
 
Labreportofai
LabreportofaiLabreportofai
Labreportofai
 
Ailabreport
AilabreportAilabreport
Ailabreport
 
artificial intelligence
artificial intelligence artificial intelligence
artificial intelligence
 
Compiler designs presentation final
Compiler designs presentation  finalCompiler designs presentation  final
Compiler designs presentation final
 
Compiler designs presentation by group 2 final final
Compiler designs presentation by group 2 final finalCompiler designs presentation by group 2 final final
Compiler designs presentation by group 2 final final
 
Assmemble langauge for slideshare.net
Assmemble langauge for slideshare.netAssmemble langauge for slideshare.net
Assmemble langauge for slideshare.net
 
Phpfundamnetalfromtutplus
PhpfundamnetalfromtutplusPhpfundamnetalfromtutplus
Phpfundamnetalfromtutplus
 
Assignment complier design (GROUP1)
Assignment complier design (GROUP1)Assignment complier design (GROUP1)
Assignment complier design (GROUP1)
 
Lisp programming
Lisp programmingLisp programming
Lisp programming
 
Lispprograaming excercise
Lispprograaming excerciseLispprograaming excercise
Lispprograaming excercise
 
Assembly lab up to 6 up (1)
Assembly lab up to 6 up (1)Assembly lab up to 6 up (1)
Assembly lab up to 6 up (1)
 
Event design
Event designEvent design
Event design
 
Vlan
VlanVlan
Vlan
 
Data communications
Data communicationsData communications
Data communications
 
Microprocessor projec ts
Microprocessor projec tsMicroprocessor projec ts
Microprocessor projec ts
 
Sql functions
Sql functionsSql functions
Sql functions
 

Dernier

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Dernier (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

Oop features java presentationshow

  • 1.
  • 2. PRESENTATION SUBMIT TO Saiful islam(16339202030) Hamida Sultana Ilias Ahmed(16339202142)
  • 3. Submit To: Tanjea Anne Lecturer of cse dept. Peoples university of bangladesh
  • 4.
  • 5. Object-oriented programming System(OOPs) is a programming paradigm based on the concept of “objects” that contain data and methods. The primary purpose of object-oriented programming is to increase the flexibility and maintainability of programs. Object oriented programming brings together data and its behaviour(methods) in a single location(object) makes it easier to understand how a program works. We will cover each and every feature of OOPs in detail so that you won’t face any difficultly understanding OOPs Concepts. OOPs Concepts – Table of Contents What is an Object What is a class Constructor in Java Object Oriented Programming Features Abstraction Encapsulation Inheritance
  • 6. What is an Object Object: is a bundle of data and its behavior(often known as methods). Objects have two characteristics: They have states and behaviors. Examples of states and behaviors Example 1: Object: House State: Address, Color, Area Behavior: Open door, close door
  • 7. class House { String address; String color; double are; void openDoor() { //Write code here } void closeDoor() { //Write code here } ... } method object properties
  • 8. Example 2 : Let’s take another example. Object: Car State: Color, Brand, Weight, Model Behavior: Break, Accelerate, Slow Down, Gear change. the states and behaviors of an object, can be represented by variables and methods in the class respectively.
  • 9. What is a Class in OOPs Concepts A class can be considered as a blueprint using which you can create as many objects as you like. For example, here we have a class Website that has two data members (also known as fields, instance variables and object states). This is just a blueprint, it does not represent any website, however using this we can create Website objects (or instances) that represents the websites. We have created two objects, while creating objects we provided separate properties to the objects using constructor. public class Website { String webName; int webAge; Website(String name, int age) { this.webName = name; this.webAge = age; } public static void main(String args[]){ //Creating objects Website obj1 = new Website(“ilias.com", 5); Website obj2 = new Website("google.com", 18); //Accessing object data through reference System.out.println(obj1.webName+" "+obj1.webAge); System.out.println(obj2.webName+" "+obj2.webAge); } }
  • 10. What is a Constructor Constructor looks like a method but it is in fact not a method. It’s name is same as class name and it does not return any value. You must have seen this statement in almost all the programs I have shared above: MyClass obj = new MyClass(); If you look at the right side of this statement, we are calling the default constructor of class myClassto create a new object (or instance).
  • 11. Example of constructor public class ConstructorExample { int age; String name; //Default constructor ConstructorExample() { this.name=“ilias"; this.age=40; } //Parameterized constructor ConstructorExample(String n,int a) { this.name=n; this.age=a; } public static void main(String args[]){ ConstructorExample obj1 = new ConstructorExample(); ConstructorExample obj2 = new ConstructorExample("Saiful", 26); System.out.println(obj1.name+" "+obj1.age); System.out.println(obj2.name+" "+obj2.age); } }
  • 12.
  • 13. Abstraction One of the most fundamental concept of OOPs is Abstraction. Abstraction is a process where you show only “relevant” data and “hide” unnecessary details of an object from the user. For example, when you login to your Amazon account online, you enter your user_id and password and press login, what happens when you press login, how the input data sent to amazon server, how it gets verified is all abstracted away from the you. Another example of abstraction: A car in itself is a well-defined object, which is composed of several other smaller objects like a gearing system, steering mechanism, engine, which are again have their own subsystems. But for humans car is a one single object, which can be managed by the help of its subsystems, even if their inner details are unknown.
  • 14. public abstract class Employee { private String name; private String address; private int number; public Employee(String name, String address, int number) { System.out.println("Constructing an Employee"); this.name = name; this.address = address; this.number = number; } public double computePay() { System.out.println("Inside Employee computePay"); return 0.0; } public void mailCheck() { System.out.println("Mailing a check to " + this.name + " " + this.address); } public String toString() { return name + " " + address + " " + number; } public String getName() { return name; } public String getAddress() { return address; } public void setAddress(String newAddress) { address = newAddress; } public int getNumber() { return number; } }
  • 15. What is encapsulation? The whole idea behind encapsulation is to hide the implementation details from users. If a data member is private it means it can only be accessed within the same class. No outside class can access private data member (variable) of other class. However if we setup public getter and setter methods to update (for example void setSSN(int ssn))and read (for example int getSSN()) the private data fields then the outside class can access those private data fields via public methods.
  • 16. class EncapsulationDemo{ private int ssn; private String empName; private int empAge; //Getter and Setter methods public int getEmpSSN(){ return ssn; } public String getEmpName(){ return empName; } public int getEmpAge(){ return empAge; } public void setEmpAge(int newValue){ empAge = newValue; } public void setEmpName(String newValue){ empName = newValue; } public void setEmpSSN(int newValue){ ssn = newValue; } } public class EncapsTest{ public static void main(String args[]){ EncapsulationDemo obj = new EncapsulationDemo(); obj.setEmpName(“ilias"); obj.setEmpAge(38); obj.setEmpSSN(112242); System.out.println("Employee Name: " + obj.getEmpName()); System.out.println("Employee SSN: " + obj.getEmpSSN()); System.out.println("Employee Age: " + obj.getEmpAge()); } }
  • 17. The process by which one class acquires the properties(data members) and functionalities(methods) of another class is called inheritance. The aim of inheritance is to provide the reusability of code so that a class has to write only the unique features and rest of the common properties and functionalities can be extended from the another class. Child Class: The class that extends the features of another class is known as child class, sub class or derived class. Parent Class: The class whose properties and functionalities are used(inherited) by another class is known as parent class, super class or Base class. Inheritance is a process of defining a new class based on an existing class by extending its common data members and methods. Inheritance allows us to reuse of code, it improves reusability in your java application. Note: The biggest advantage of Inheritance is that the code that is already present in base class need not be rewritten in the child class. Syntax: Inheritance in Java To inherit a class we use extends keyword. Here class XYZ is child class and class ABC is parent class. The class XYZ is inheriting the properties and methods of ABC class. class XYZ extends ABC { }
  • 18. Inheritance Example class Teacher { String designation = "Teacher"; String collegeName = “pub"; void does(){ System.out.println("Teaching"); } } public class PhysicsTeacher extends Teacher{ String mainSubject = "Physics"; public static void main(String args[]){ PhysicsTeacher obj = new PhysicsTeacher(); System.out.println(obj.collegeName); System.out.println(obj.designation); System.out.println(obj.mainSubject); obj.does(); } }
  • 19. Types of inheritance To learn types of inheritance in detail, refer: Types of Inheritance in Java. Single Inheritance: refers to a child and parent class relationship where a class extends the another class.
  • 20. Polymorphism This post provides the theoretical explanation of polymorphism with real-life examples. For detailed explanation on this topic with java programs refer polymorphism in java and runtime & compile time polymorphism. Polymorphism means to process objects differently based on their data type. In other words it means, one method with multiple implementation, for a certain class of action. And which implementation to be used is decided at runtime depending upon the situation (i.e., data type of the object) This can be implemented by designing a generic interface, which provides generic methods for a certain class of action and there can be multiple classes, which provides the implementation of these generic methods.
  • 21. Polymorphism could be static and dynamic both. Method Overloading is static polymorphism while, Method overriding is dynamic polymorphism. Overloading in simple words means more than one method having the same method name that behaves differently based on the arguments passed while calling the method. This called static because, which method to be invoked is decided at the time of compilation Overriding means a derived class is implementing a method of its super class. The call to overriden method is resolved at runtime, thus called runtime polymorphism
  • 22. Types of polymorphism in java- Runtime and Compile time polymorphism types of polymorphism. There are two types of polymorphism in java: 1) Static Polymorphism also known as compile time polymorphism 2) Dynamic Polymorphism also known as runtime polymorphism
  • 23. Compile time Polymorphism (or Static polymorphism) Polymorphism that is resolved during compiler time is known as static polymorphism. Method overloading is an example of compile time polymorphism. Method Overloading: This allows us to have more than one method having the same name, if the parameters of methods are different in number, sequence and data types of parameters. We have already discussed Method overloading here: If you didn’t read that guide, refer: Method Overloading in Java
  • 24. Example of static Polymorphism class SimpleCalculator { int add(int a, int b) { return a+b; } int add(int a, int b, int c) { return a+b+c; } } public class Demo { public static void main(String args[]) { SimpleCalculator obj = new SimpleCalculator(); System.out.println(obj.add(10, 20)); System.out.println(obj.add(10, 20, 30)); } } Output: 30 60
  • 25. Runtime Polymorphism (or Dynamic polymorphism) Dynamic polymorphism is a process in which a call to an overridden method is resolved at runtime, thats why it is called runtime polymorphism. I have already discussed method overriding in detail in a separate tutorial, refer it: Method Overriding in Java.
  • 26. Example In this example we have two classes ABC and XYZ. ABC is a parent class and XYZ is a child class. The child class is overriding the method myMethod() of parent class.
  • 27. class ABC{ public void myMethod(){ System.out.println("Overridden Method"); } } public class XYZ extends ABC{ public void myMethod(){ System.out.println("Overriding Method"); } public static void main(String args[]){ ABC obj = new XYZ(); obj.myMethod(); } } Design by ilias