SlideShare a Scribd company logo
1 of 23
Junayed Ahmed
Hasnat Hridoy
Ajoy Saha
M A Murad
Aong Sing
Static keyword
The static keyword is a non-access modifier used for methods
and attributes. Static methods/attributes can be accessed
without creating an object of a class
Static keyword can be used in
1.Static variable
2.static Method
3.Static Block
Why should we use Static Keyword?
1.Static keyword is used For memory management
2.It makes program more efficient by saving memory
package StaticVariable;
public class Student {
String name;
int id;
static String university="Diu";
Student(String n,int id){
this.name=n;
this.id=id;
}
void display() {
System.out.println("Name :"+name);
System.out.println("id :"+id);
System.out.println("University name:"+university);
}
public static void main(String[]args) {
Student s1=new Student("Hasnat",101);
Student s2=new Student("Junayed",102);
s1.display();
s2.display();
Static Method does not require object declaration
package staticMethod;
public class StaticMethod {
void display1() {
System.out.println("I am non static method");
}
static void dispalay2() {
System.out.println("I am static method");
}
public static void main(String[] args) {
StaticMethod ob1=new StaticMethod();
ob1.display1();
Static Method
Some restriction on Static Method
1.static method can't use non static member
2. “this” and “super” keywords can't be use in static method
3.static can't use non static but can use static
Static Block
package staticBlock;
public class block {
static int id;
static String name;
static {
id= 101;
name="Abul Hasnat HRidoy";
}
static void display() {
System.out.println("ID :"+id);
System.out.println("Name :"+
name);
}
public static void main(String[] args) {
block.display();
Encapsulation is a way to restrict the direct access to
some components of an object, so users cannot access
state values for all of the variables of a particular object.
Encapsulation can be used to hide both data members
and data functions or methods associated with an
instantiated class or object.
What is encapsulation?
Mozadded Alfeshani Murad
221-15-6047
Mozadded Alfeshani Murad
221-15-6047
Encapsulation
Real world example of encapsulation :
The bag contains different stuffs like pen, pencil,
notebook etc within it, in order to get any stuff you
need to open that bag, similarly in java an
encapsulation unit contains its data and behavior
within it and in order to access them you need an
object of that unit.
Private Value Inaccessible
class
User Class
How to make it accessible :
user class
class
Mozadded Alfeshani Murad
221-15-6047
Benefits of encapsulation programming
Encapsulation in programming has a few key
benefits.
Hiding data: Users will have no idea how classes are
being implemented or stored. All that users will know is
that values are being passed and initialized.
More flexibility: Enables you to set variables as red or
write-only. Examples include: setName(), setAge() or
to set variables as write-only then you only need to
omit the get methods like getName(), getAge() etc.
Easy to reuse: With encapsulation, it's easy to change
and adapt to new requirements
What is inheritance?
Inheritance is a mechanism in which one class acquires
all the properties and behaviors of a parent class.
In Java using “extends” keyword we inherit one class to
Another.
Why do we need Inheritance?
i.For code Reusability
ii.For method overriding
iii.To implement parent child relationship
INHERITANCE
Types of Inheritance in Java:
1.Single Level Inheritance
2.MultiLevel Inheritance
3. Hierarchical Inheritance
Single Level Inheritance:
When a class inherits another class, it is known as a single level inheritance
Multilevel Inheritance:
When there is a chain of inheritance, it is known as multilevel inheritance.
Hierarchical Inheritance:
When two or more classes inherits a single class, it is known as hierarchical inheritance.
Polymorphism
Polymorphism is the ability of an object to take on many forms. It allows
objects of different classes to be treated as same type.
● It provides flexibility to the code by taking multiple forms.
● It simplifies the code by providing a unified interface.
Polymorphism
Method overriding
Method overriding is the ability of a subclass to
provide its own implementation of a method.
Method overloading
Method overloading is when a class
provides multiple methods with the
same name but different parameters
Polymorphism can be achieved in Java in two ways
Example of Method Overriding
Example of Method Overloading
OOP_presentation.pptx
OOP_presentation.pptx

More Related Content

Similar to OOP_presentation.pptx

Lecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptxLecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptx
ShahinAhmed49
 
"Study of Java Access Control Mechanism”
"Study of Java Access Control Mechanism”"Study of Java Access Control Mechanism”
"Study of Java Access Control Mechanism”
IOSR Journals
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
ArpitaJana28
 

Similar to OOP_presentation.pptx (20)

Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1
 
Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
 
Encapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important pillerEncapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important piller
 
Encapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important pillerEncapsulation C++ Piller of OOP it is the important piller
Encapsulation C++ Piller of OOP it is the important piller
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
 
Lecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptxLecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptx
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
 
Java presentation
Java presentationJava presentation
Java presentation
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Selenium Training .pptx
Selenium Training .pptxSelenium Training .pptx
Selenium Training .pptx
 
Object oriented programming CLASSES-AND-OBJECTS.pptx
Object oriented programming CLASSES-AND-OBJECTS.pptxObject oriented programming CLASSES-AND-OBJECTS.pptx
Object oriented programming CLASSES-AND-OBJECTS.pptx
 
OOP in Python, a beginners guide..........
OOP in Python, a beginners guide..........OOP in Python, a beginners guide..........
OOP in Python, a beginners guide..........
 
"Study of Java Access Control Mechanism”
"Study of Java Access Control Mechanism”"Study of Java Access Control Mechanism”
"Study of Java Access Control Mechanism”
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
27c
27c27c
27c
 
27csharp
27csharp27csharp
27csharp
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 

Recently uploaded

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 

OOP_presentation.pptx

  • 1.
  • 2. Junayed Ahmed Hasnat Hridoy Ajoy Saha M A Murad Aong Sing
  • 3. Static keyword The static keyword is a non-access modifier used for methods and attributes. Static methods/attributes can be accessed without creating an object of a class Static keyword can be used in 1.Static variable 2.static Method 3.Static Block
  • 4. Why should we use Static Keyword? 1.Static keyword is used For memory management 2.It makes program more efficient by saving memory
  • 5. package StaticVariable; public class Student { String name; int id; static String university="Diu"; Student(String n,int id){ this.name=n; this.id=id; } void display() { System.out.println("Name :"+name); System.out.println("id :"+id); System.out.println("University name:"+university); } public static void main(String[]args) { Student s1=new Student("Hasnat",101); Student s2=new Student("Junayed",102); s1.display(); s2.display();
  • 6. Static Method does not require object declaration package staticMethod; public class StaticMethod { void display1() { System.out.println("I am non static method"); } static void dispalay2() { System.out.println("I am static method"); } public static void main(String[] args) { StaticMethod ob1=new StaticMethod(); ob1.display1(); Static Method
  • 7. Some restriction on Static Method 1.static method can't use non static member 2. “this” and “super” keywords can't be use in static method 3.static can't use non static but can use static
  • 8. Static Block package staticBlock; public class block { static int id; static String name; static { id= 101; name="Abul Hasnat HRidoy"; } static void display() { System.out.println("ID :"+id); System.out.println("Name :"+ name); } public static void main(String[] args) { block.display();
  • 9. Encapsulation is a way to restrict the direct access to some components of an object, so users cannot access state values for all of the variables of a particular object. Encapsulation can be used to hide both data members and data functions or methods associated with an instantiated class or object. What is encapsulation? Mozadded Alfeshani Murad 221-15-6047
  • 10. Mozadded Alfeshani Murad 221-15-6047 Encapsulation Real world example of encapsulation : The bag contains different stuffs like pen, pencil, notebook etc within it, in order to get any stuff you need to open that bag, similarly in java an encapsulation unit contains its data and behavior within it and in order to access them you need an object of that unit.
  • 11. Private Value Inaccessible class User Class How to make it accessible : user class class
  • 12. Mozadded Alfeshani Murad 221-15-6047 Benefits of encapsulation programming Encapsulation in programming has a few key benefits. Hiding data: Users will have no idea how classes are being implemented or stored. All that users will know is that values are being passed and initialized. More flexibility: Enables you to set variables as red or write-only. Examples include: setName(), setAge() or to set variables as write-only then you only need to omit the get methods like getName(), getAge() etc. Easy to reuse: With encapsulation, it's easy to change and adapt to new requirements
  • 13. What is inheritance? Inheritance is a mechanism in which one class acquires all the properties and behaviors of a parent class. In Java using “extends” keyword we inherit one class to Another. Why do we need Inheritance? i.For code Reusability ii.For method overriding iii.To implement parent child relationship INHERITANCE
  • 14. Types of Inheritance in Java: 1.Single Level Inheritance 2.MultiLevel Inheritance 3. Hierarchical Inheritance Single Level Inheritance: When a class inherits another class, it is known as a single level inheritance
  • 15.
  • 16. Multilevel Inheritance: When there is a chain of inheritance, it is known as multilevel inheritance.
  • 17. Hierarchical Inheritance: When two or more classes inherits a single class, it is known as hierarchical inheritance.
  • 18. Polymorphism Polymorphism is the ability of an object to take on many forms. It allows objects of different classes to be treated as same type. ● It provides flexibility to the code by taking multiple forms. ● It simplifies the code by providing a unified interface.
  • 19. Polymorphism Method overriding Method overriding is the ability of a subclass to provide its own implementation of a method. Method overloading Method overloading is when a class provides multiple methods with the same name but different parameters Polymorphism can be achieved in Java in two ways
  • 20. Example of Method Overriding
  • 21. Example of Method Overloading

Editor's Notes

  1. Mozadded Alfeshani Murad
  2. Mozadded Alfeshani Murad