Object Oriented Programming with Java
Upcoming SlideShare
Loading in...5
×
 

Object Oriented Programming with Java

on

  • 12,764 views

 

Statistics

Views

Total Views
12,764
Views on SlideShare
10,497
Embed Views
2,267

Actions

Likes
15
Downloads
1,182
Comments
5

13 Embeds 2,267

http://www.victusspiritus.com 1729
http://www.ustudy.in 437
http://ustudy.in 44
http://www.futureforyou.biz 20
http://www.blogger.com 12
http://www.brijj.com 9
http://www.slideshare.net 5
http://webcache.googleusercontent.com 3
http://translate.googleusercontent.com 3
http://elearning4.tarc.edu.my 2
https://cunyuat.blackboard.com 1
http://wildfire.gigya.com 1
https://bbupgrade.cuny.edu 1
More...

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

15 of 5 Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • interesting
    Are you sure you want to
    Your message goes here
    Processing…
  • There r errors on Page 24.
    Are you sure you want to
    Your message goes here
    Processing…
  • thanks
    Are you sure you want to
    Your message goes here
    Processing…
  • SUPERB PRESENTATIONSS
    Are you sure you want to
    Your message goes here
    Processing…
  • great useful presentation!
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Object Oriented Programming with Java Object Oriented Programming with Java Presentation Transcript

    • 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); } }