SlideShare a Scribd company logo
IADCS Diploma Course Object Oriented Programming U Nyein Oo COO/Director(IT) Myanma Computer Co., Ltd(MCC)
OOP? Software Development Technique Effective use of programmer productivity Way of Creating Large Scale Systems Approaching 100% solution
Basic Concepts Object Class Inheritance Polymorphism Encapsulation Data Abstraction
Object A Person, Place or Concepts Composed of Characteristics (data) and Behavior (Operation) Can operate directly on its data Interact sending message to each other
Class Structure that contains common data and function as entity for objects Each object is an instance of a class
Inheritance The mechanism that permits a class to share the attributes and operations defined in one or more classes
Inheritance(cont) Subclass The class which inherits from another class Super class The class from which another class inherits its behavior Multiple Inheritance A subclass inherits from two or more classes
Polymorphism The property that allows an operation to have different behavior on different objects
Encapsulation The process of binding data and methods together is known as encapsulation
Data Abstraction The process of identifying and grouping attributes and actions related to a particular entity as relevant to the application a hand. Advantages - It focus on the problem - It identifies the essential characteristics and  action  - It helps the eliminate unnecessary details.
Access Specifiers Public  Private Protected
Method Modifiers Static Abstract Final Native Volatile
Use of Modifiers No Yes No Volatile No No Yes Native Yes Yes Yes Final Yes No Yes Abstract Yes(nested) Yes Yes Protected Yes(nested) Yes Yes Private Yes Yes Yes Public Class Variable Method Modifier
Construction The process of bringing an object into existence is called construction A construction - Allocates memory -  Initializes attributes, if any - Enables access to attributes and methods
Constructor (cont) Explicit constructor User defined constructor in class definition Implicit constructor Default constructor which is provided by JVM
Destruction The process of deleting an objects is called destruction A destructor -  Frees allocated space - Disable access to attributes and methods
Method Overloading In the same class and same methods name But in different parameters and data types Form of compile time polymorphism
Method Overridden In the super class as well as subclass Allows general classes to specify methods that will common to its subclass Form of runtime polymorphism
Abstract class and method There is no code in abstract class and method Must be declared as abstract type Can not instantiated At least one abstract method in class
Writing Abstract class and Method abstract class GraphicObject  {  int x, y;   . . .  void moveTo(int newX, int newY)  { . . .  }  abstract void draw();  }
Interface A special kind of a class which consists of only the constants and the method prototypes Practically is Java substitute of multiple inheritance A class can implement multiple interfaces
Interface Vs Abstract Class A third party class must be rewritten to extend only from the abstract class. An interface implementation may be added to any existing third party classes Third party convenience Both instance and static constant are possible Static final constants only Constants An abstract class can provide complete code, default code An interface can’t provide any code at all Default implementation A class may extend only one abstract class A class May implement several interfaces. Multiple Inheritance Abstract Class Interface Feature
Package The group of classes and interfaces Can be used other java standard packages Need to specified class paths for it
Package and Access Control yes Yes No Yes Different package non-subclass Yes Yes No Yes Different package subclass Yes Yes No Yes Same package non-subclass Yes Yes No Yes Same package subclass Yes Yes Yes Yes Same class No modifier Protected Private Public
Example Java Package Java.lang Java.applet Java.awt Java.io Java.util Java.net Java.rmi….etc
//Constructor Example class Constructor_test{ public Constructor_test() { System.out.println("Hello "); } public Constructor_test(String txt) { System.out.println("Hello "+txt); } public static void main(String args[]) { Constructor_test obj=new Constructor_test(); Constructor_test obj2=new Constructor_test(args[0]); } }
Method Overloading class Method_overload{ public void Show(){ System.out.println("Hello Myanmar"); } public static int Show(int num){ int a=num+10; return a; } public static void main(String args[]){ Method_overload obj=new Method_overload(); obj.Show(); int num=Show(320); System.out.println(num); } }
Inheritance Example class Super{ public void Show(){ System.out.println("Hello"); } } class Sub extends Super{ public static void main(String args[]){ Sub obj=new Sub(); obj.Show(); } }
Method overridden Example class Super{ public void Show(){ System.out.println("Hello"); } } class Sub extends Super{ public void Show(int num){ System.out.println("Hello "+num); } public static void main(String args[]){ Sub obj=new Sub(); obj.Show(); obj.Show(20); } }
Example for Constructors //Constructor and Overloaded Constructor class Me{ public Me(){ System.out.println("Hello Constructor"); } public Me(String arg){ System.out.println("Hello " +arg); } public static void main(String args[]){ Me obj=new Me(); // implicit Me obj1=new Me("OverLoaded Constructor"); } }
Method and Overloaded Method //Method and Overloaded Method class Me{ public void Show(){ System.out.println("Hello Method"); } public void Show(String arg){ System.out.println("Hello " +arg); } public static void main(String args[]){ Me obj=new Me(); obj.Show(); obj.Show("Overloaded Method"); } }
Overridden Method class Me{ public void Show(){ System.out.println("Hello Method"); } } class Sub extends Me{ public void Show(String arg){ System.out.println("Hello " +arg); } public static void main(String args[]){ Sub obj=new Sub(); obj.Show(); obj.Show("Overloaded Method"); } }
Generation Interface //interface example  public interface MyInterface{ public void add(int x,int y); }
Implementing Interface class Demo implements MyInterface{ public void add(int x,int y){ System.out.println("  "+(x+y)); } public static void main(String args[]){ Demo obj=new Demo(); obj.add(20,30); } }
Generating Package package MyPackage; public class Compute{ public int Add(int x,int y){ return (x+y); } public int Subtract(int x,int y){ return (x-y); } public int Multiply(int x,int y){ return (x*y); } public int Divide(int x,int y){ return (x/y); } }
Applying Package import MyPackage.*; class PKDemo{ public static void main(String args[]){ Compute obj=new Compute(); int sum=obj.Add(10,20); int sub=obj.Subtract(20,10); System.out.println("the total is "+sum); System.out.println("the minus is "+sub); } }

More Related Content

What's hot (20)

PPTX
Classes, objects in JAVA
Abhilash Nair
 
PPTX
Type casting in java
Farooq Baloch
 
PPTX
Java programming course for beginners
Eduonix Learning Solutions
 
PPSX
JDBC: java DataBase connectivity
Tanmoy Barman
 
PPT
Object Oriented Programming Concepts
thinkphp
 
PDF
Methods in Java
Jussi Pohjolainen
 
PPT
The Evolution of Java
Fu Cheng
 
PPTX
Functional programming with Java 8
LivePerson
 
PDF
Introduction to Java Programming
Ravi Kant Sahu
 
PPTX
Java fx
Rohit Vaidya
 
PPTX
Advance Java Topics (J2EE)
slire
 
PPS
Introduction to class in java
kamal kotecha
 
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
PPTX
JavaFX Presentation
Mochamad Taufik Mulyadi
 
PPTX
oops concept in java | object oriented programming in java
CPD INDIA
 
PPT
Object-oriented concepts
BG Java EE Course
 
PPSX
Exception Handling
Reddhi Basu
 
PPTX
Polymorphism presentation in java
Ahsan Raja
 
PPTX
Strings in Java
Abhilash Nair
 
PDF
Collections In Java
Binoj T E
 
Classes, objects in JAVA
Abhilash Nair
 
Type casting in java
Farooq Baloch
 
Java programming course for beginners
Eduonix Learning Solutions
 
JDBC: java DataBase connectivity
Tanmoy Barman
 
Object Oriented Programming Concepts
thinkphp
 
Methods in Java
Jussi Pohjolainen
 
The Evolution of Java
Fu Cheng
 
Functional programming with Java 8
LivePerson
 
Introduction to Java Programming
Ravi Kant Sahu
 
Java fx
Rohit Vaidya
 
Advance Java Topics (J2EE)
slire
 
Introduction to class in java
kamal kotecha
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
JavaFX Presentation
Mochamad Taufik Mulyadi
 
oops concept in java | object oriented programming in java
CPD INDIA
 
Object-oriented concepts
BG Java EE Course
 
Exception Handling
Reddhi Basu
 
Polymorphism presentation in java
Ahsan Raja
 
Strings in Java
Abhilash Nair
 
Collections In Java
Binoj T E
 

Similar to Object Oriented Programming with Java (20)

PPTX
Introduction to OOPs second year cse.pptx
solemanhldr
 
PPTX
ITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUE
VinishA23
 
PDF
OOPs Concepts - Android Programming
Purvik Rana
 
DOCX
JAVA Notes - All major concepts covered with examples
Sunil Kumar Gunasekaran
 
PPT
Jedi slides 2.1 object-oriented concepts
Maryo Manjaruni
 
PPTX
Java chapter 5
Abdii Rashid
 
PDF
JAVA-PPT'S.pdf
AnmolVerma363503
 
PPTX
L02 Software Design
Ólafur Andri Ragnarsson
 
PPTX
Object oriented programming
Saiful Islam Sany
 
PPTX
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
PPTX
JAVA-PPT'S.pptx
RaazIndia
 
PPTX
introduction to object oriented programming language java
RitikGarg39
 
PDF
Java/J2EE interview Qestions
Arun Vasanth
 
PPTX
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
mohanrajm63
 
PPTX
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
PPTX
Object oriented programming
MH Abid
 
PPTX
Java presentation
Akteruzzaman .
 
PPTX
Basics of oops concept
DINESH KUMAR ARIVARASAN
 
PPT
Chap11
Terry Yoast
 
Introduction to OOPs second year cse.pptx
solemanhldr
 
ITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUE
VinishA23
 
OOPs Concepts - Android Programming
Purvik Rana
 
JAVA Notes - All major concepts covered with examples
Sunil Kumar Gunasekaran
 
Jedi slides 2.1 object-oriented concepts
Maryo Manjaruni
 
Java chapter 5
Abdii Rashid
 
JAVA-PPT'S.pdf
AnmolVerma363503
 
L02 Software Design
Ólafur Andri Ragnarsson
 
Object oriented programming
Saiful Islam Sany
 
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
JAVA-PPT'S.pptx
RaazIndia
 
introduction to object oriented programming language java
RitikGarg39
 
Java/J2EE interview Qestions
Arun Vasanth
 
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
mohanrajm63
 
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
Object oriented programming
MH Abid
 
Java presentation
Akteruzzaman .
 
Basics of oops concept
DINESH KUMAR ARIVARASAN
 
Chap11
Terry Yoast
 
Ad

More from backdoor (20)

PPT
Java Database Connectivity
backdoor
 
PPT
Distributed Programming using RMI
backdoor
 
PPT
Programming Server side with Sevlet
backdoor
 
PPT
Distributed Programming using RMI
backdoor
 
PPT
Client Side Programming with Applet
backdoor
 
PPT
Java Network Programming
backdoor
 
PPT
Windows Programming with Swing
backdoor
 
PPT
Windows Programming with AWT
backdoor
 
PPT
Multithreading
backdoor
 
PPT
Object and Classes in Java
backdoor
 
PPT
IO and serialization
backdoor
 
PPT
Exception Handling
backdoor
 
PPT
Java Intro
backdoor
 
PPT
AWT Program output
backdoor
 
PPT
Net Man
backdoor
 
PPT
Data Security
backdoor
 
PPT
Ne Course Part One
backdoor
 
PPT
Ne Course Part Two
backdoor
 
PPT
Net Sec
backdoor
 
PDF
Security Policy Checklist
backdoor
 
Java Database Connectivity
backdoor
 
Distributed Programming using RMI
backdoor
 
Programming Server side with Sevlet
backdoor
 
Distributed Programming using RMI
backdoor
 
Client Side Programming with Applet
backdoor
 
Java Network Programming
backdoor
 
Windows Programming with Swing
backdoor
 
Windows Programming with AWT
backdoor
 
Multithreading
backdoor
 
Object and Classes in Java
backdoor
 
IO and serialization
backdoor
 
Exception Handling
backdoor
 
Java Intro
backdoor
 
AWT Program output
backdoor
 
Net Man
backdoor
 
Data Security
backdoor
 
Ne Course Part One
backdoor
 
Ne Course Part Two
backdoor
 
Net Sec
backdoor
 
Security Policy Checklist
backdoor
 
Ad

Recently uploaded (20)

PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Biography of Daniel Podor.pdf
Daniel Podor
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
July Patch Tuesday
Ivanti
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 

Object Oriented Programming with Java

  • 1. IADCS Diploma Course Object Oriented Programming U Nyein Oo COO/Director(IT) Myanma Computer Co., Ltd(MCC)
  • 2. OOP? Software Development Technique Effective use of programmer productivity Way of Creating Large Scale Systems Approaching 100% solution
  • 3. Basic Concepts Object Class Inheritance Polymorphism Encapsulation Data Abstraction
  • 4. Object A Person, Place or Concepts Composed of Characteristics (data) and Behavior (Operation) Can operate directly on its data Interact sending message to each other
  • 5. Class Structure that contains common data and function as entity for objects Each object is an instance of a class
  • 6. Inheritance The mechanism that permits a class to share the attributes and operations defined in one or more classes
  • 7. Inheritance(cont) Subclass The class which inherits from another class Super class The class from which another class inherits its behavior Multiple Inheritance A subclass inherits from two or more classes
  • 8. Polymorphism The property that allows an operation to have different behavior on different objects
  • 9. Encapsulation The process of binding data and methods together is known as encapsulation
  • 10. Data Abstraction The process of identifying and grouping attributes and actions related to a particular entity as relevant to the application a hand. Advantages - It focus on the problem - It identifies the essential characteristics and action - It helps the eliminate unnecessary details.
  • 11. Access Specifiers Public Private Protected
  • 12. Method Modifiers Static Abstract Final Native Volatile
  • 13. Use of Modifiers No Yes No Volatile No No Yes Native Yes Yes Yes Final Yes No Yes Abstract Yes(nested) Yes Yes Protected Yes(nested) Yes Yes Private Yes Yes Yes Public Class Variable Method Modifier
  • 14. Construction The process of bringing an object into existence is called construction A construction - Allocates memory - Initializes attributes, if any - Enables access to attributes and methods
  • 15. Constructor (cont) Explicit constructor User defined constructor in class definition Implicit constructor Default constructor which is provided by JVM
  • 16. Destruction The process of deleting an objects is called destruction A destructor - Frees allocated space - Disable access to attributes and methods
  • 17. Method Overloading In the same class and same methods name But in different parameters and data types Form of compile time polymorphism
  • 18. Method Overridden In the super class as well as subclass Allows general classes to specify methods that will common to its subclass Form of runtime polymorphism
  • 19. Abstract class and method There is no code in abstract class and method Must be declared as abstract type Can not instantiated At least one abstract method in class
  • 20. Writing Abstract class and Method abstract class GraphicObject { int x, y; . . . void moveTo(int newX, int newY) { . . . } abstract void draw(); }
  • 21. Interface A special kind of a class which consists of only the constants and the method prototypes Practically is Java substitute of multiple inheritance A class can implement multiple interfaces
  • 22. Interface Vs Abstract Class A third party class must be rewritten to extend only from the abstract class. An interface implementation may be added to any existing third party classes Third party convenience Both instance and static constant are possible Static final constants only Constants An abstract class can provide complete code, default code An interface can’t provide any code at all Default implementation A class may extend only one abstract class A class May implement several interfaces. Multiple Inheritance Abstract Class Interface Feature
  • 23. Package The group of classes and interfaces Can be used other java standard packages Need to specified class paths for it
  • 24. Package and Access Control yes Yes No Yes Different package non-subclass Yes Yes No Yes Different package subclass Yes Yes No Yes Same package non-subclass Yes Yes No Yes Same package subclass Yes Yes Yes Yes Same class No modifier Protected Private Public
  • 25. Example Java Package Java.lang Java.applet Java.awt Java.io Java.util Java.net Java.rmi….etc
  • 26. //Constructor Example class Constructor_test{ public Constructor_test() { System.out.println("Hello "); } public Constructor_test(String txt) { System.out.println("Hello "+txt); } public static void main(String args[]) { Constructor_test obj=new Constructor_test(); Constructor_test obj2=new Constructor_test(args[0]); } }
  • 27. Method Overloading class Method_overload{ public void Show(){ System.out.println("Hello Myanmar"); } public static int Show(int num){ int a=num+10; return a; } public static void main(String args[]){ Method_overload obj=new Method_overload(); obj.Show(); int num=Show(320); System.out.println(num); } }
  • 28. Inheritance Example class Super{ public void Show(){ System.out.println("Hello"); } } class Sub extends Super{ public static void main(String args[]){ Sub obj=new Sub(); obj.Show(); } }
  • 29. Method overridden Example class Super{ public void Show(){ System.out.println("Hello"); } } class Sub extends Super{ public void Show(int num){ System.out.println("Hello "+num); } public static void main(String args[]){ Sub obj=new Sub(); obj.Show(); obj.Show(20); } }
  • 30. Example for Constructors //Constructor and Overloaded Constructor class Me{ public Me(){ System.out.println("Hello Constructor"); } public Me(String arg){ System.out.println("Hello " +arg); } public static void main(String args[]){ Me obj=new Me(); // implicit Me obj1=new Me("OverLoaded Constructor"); } }
  • 31. Method and Overloaded Method //Method and Overloaded Method class Me{ public void Show(){ System.out.println("Hello Method"); } public void Show(String arg){ System.out.println("Hello " +arg); } public static void main(String args[]){ Me obj=new Me(); obj.Show(); obj.Show("Overloaded Method"); } }
  • 32. Overridden Method class Me{ public void Show(){ System.out.println("Hello Method"); } } class Sub extends Me{ public void Show(String arg){ System.out.println("Hello " +arg); } public static void main(String args[]){ Sub obj=new Sub(); obj.Show(); obj.Show("Overloaded Method"); } }
  • 33. Generation Interface //interface example public interface MyInterface{ public void add(int x,int y); }
  • 34. Implementing Interface class Demo implements MyInterface{ public void add(int x,int y){ System.out.println(" "+(x+y)); } public static void main(String args[]){ Demo obj=new Demo(); obj.add(20,30); } }
  • 35. Generating Package package MyPackage; public class Compute{ public int Add(int x,int y){ return (x+y); } public int Subtract(int x,int y){ return (x-y); } public int Multiply(int x,int y){ return (x*y); } public int Divide(int x,int y){ return (x/y); } }
  • 36. Applying Package import MyPackage.*; class PKDemo{ public static void main(String args[]){ Compute obj=new Compute(); int sum=obj.Add(10,20); int sub=obj.Subtract(20,10); System.out.println("the total is "+sum); System.out.println("the minus is "+sub); } }