SlideShare a Scribd company logo
1 of 28
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();
Static Method
A static method is a method that belongs to a class rather
than an instance of a class. This means you can call a static
method without creating an object of the class. Static
methods are sometimes called class methods.
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();
StaticMethod.dispalay2();
}
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
Constructor
What is Constructor???
Constructor is a special type of method that is used to initialize the object.
Constructor on JAVA is used to create the instance of the class.
It’s a method , which can be overloaded and used for initializing an object.
Constructor
Properties of Constructor
Constructor has the same name as that of the class it belongs.
Constructor is a special type of method.
It has no return type not even void.
It is called automatically.
A constructor method is always public sometime it can be protected.
If a constructor is declared an private you can’t create any object of that class.
Types of Constructor
1.Default Constructor: A default constructor is a constructor that
either has no parameters or if it has parameters, all the parameters
have default values. If there is no constructor in a class, compiler
automatically creates a default constructor.
2.Parameterized Constructor: A constructor is called parameterized
constructor when it accepts a specific number of parameters. To initialize data
members of a class with distinct values.
Default constructor and parameterized constructor
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.
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
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
INHERITANCE
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
object and method to
Another class.
Why do we need Inheritance?
i.For code Reusability
ii.For method overriding
iii.To implement parent child relationship
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 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.
Why multiple inheritance in possible in Java?
Java doesn't support multiple inheritances in classes because it can lead to diamond problem and
rather than providing some complex way to solve it, there are better ways through which we can
achieve the same result as multiple inheritances.
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

More Related Content

Similar to OOP presentation.pptx

Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core ParcticalGaurav Mehta
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPRick Ogden
 
Dev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDevLabs Alliance
 
OOP in Java Presentation.pptx
OOP in Java Presentation.pptxOOP in Java Presentation.pptx
OOP in Java Presentation.pptxmrxyz19
 
Top 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETTop 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETDevLabs Alliance
 
Dev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetDev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetdevlabsalliance
 
Lecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptxLecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptxShahinAhmed49
 
Classes, objects, methods, constructors, this keyword in java
Classes, objects, methods, constructors, this keyword  in javaClasses, objects, methods, constructors, this keyword  in java
Classes, objects, methods, constructors, this keyword in javaTharuniDiddekunta
 
Nitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitishChaulagai
 
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdfch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdfbca23189c
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfArpitaJana28
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...AnkurSingh340457
 
(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHP(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHPRick Ogden
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programmingNeelesh Shukla
 

Similar to OOP presentation.pptx (20)

Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
 
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
 
Dev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdet
 
OOP in Java Presentation.pptx
OOP in Java Presentation.pptxOOP in Java Presentation.pptx
OOP in Java Presentation.pptx
 
Java sessionnotes
Java sessionnotesJava sessionnotes
Java sessionnotes
 
Top 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETTop 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDET
 
Dev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetDev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdet
 
PPT Lecture-1.4.pptx
PPT Lecture-1.4.pptxPPT Lecture-1.4.pptx
PPT Lecture-1.4.pptx
 
CHAPTER 3 part1.pdf
CHAPTER 3 part1.pdfCHAPTER 3 part1.pdf
CHAPTER 3 part1.pdf
 
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
 
Classes, objects, methods, constructors, this keyword in java
Classes, objects, methods, constructors, this keyword  in javaClasses, objects, methods, constructors, this keyword  in java
Classes, objects, methods, constructors, this keyword in java
 
Nitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptx
 
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdfch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
 
(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHP(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHP
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 

Recently uploaded

%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 midrandmasabamasaba
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
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.pdfkalichargn70th171
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
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.pdfkalichargn70th171
 
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...Shane Coughlan
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
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 🔝✔️✔️Delhi Call girls
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
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...SelfMade bd
 
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.pdfVishalKumarJha10
 
+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
 
%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 Stilfonteinmasabamasaba
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 

Recently uploaded (20)

%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
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
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
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
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
 
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...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
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 🔝✔️✔️
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
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...
 
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
 
+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 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
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

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();
  • 6. Static Method A static method is a method that belongs to a class rather than an instance of a class. This means you can call a static method without creating an object of the class. Static methods are sometimes called class methods. Static Method does not require object declaration
  • 7. 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(); StaticMethod.dispalay2(); } Static Method
  • 8. 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
  • 9. Constructor What is Constructor??? Constructor is a special type of method that is used to initialize the object. Constructor on JAVA is used to create the instance of the class. It’s a method , which can be overloaded and used for initializing an object.
  • 10. Constructor Properties of Constructor Constructor has the same name as that of the class it belongs. Constructor is a special type of method. It has no return type not even void. It is called automatically. A constructor method is always public sometime it can be protected. If a constructor is declared an private you can’t create any object of that class.
  • 11. Types of Constructor 1.Default Constructor: A default constructor is a constructor that either has no parameters or if it has parameters, all the parameters have default values. If there is no constructor in a class, compiler automatically creates a default constructor. 2.Parameterized Constructor: A constructor is called parameterized constructor when it accepts a specific number of parameters. To initialize data members of a class with distinct values.
  • 12. Default constructor and parameterized constructor
  • 13. 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.
  • 14. 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
  • 15. Private Value Inaccessible class User Class How to make it accessible : user class class
  • 16. 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
  • 18. 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 object and method to Another class. Why do we need Inheritance? i.For code Reusability ii.For method overriding iii.To implement parent child relationship
  • 19. 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 inheritance
  • 20.
  • 21. Multilevel Inheritance: When there is a chain of inheritance, it is known as multilevel inheritance.
  • 22. Hierarchical Inheritance: When two or more classes inherits a single class, it is known as hierarchical inheritance.
  • 23. Why multiple inheritance in possible in Java? Java doesn't support multiple inheritances in classes because it can lead to diamond problem and rather than providing some complex way to solve it, there are better ways through which we can achieve the same result as multiple inheritances.
  • 24. 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.
  • 25. 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
  • 26. Example of Method Overriding
  • 27. Example of Method Overloading

Editor's Notes

  1. Mozadded Alfeshani Murad
  2. Mozadded Alfeshani Murad