Topic 3 : Introduction to
Object Orientation
DDOOCP
Terminologies
› Encapsulation
› Polymorphism
› Inheritance
› Method Overriding
› final Keyword
› Abstract class and method...
4 major principles of OOP
1. Encapsulation
2. Abstraction
3. Polymorphism
4. Inheritance
Encapsulation
› Encapsulation is the hiding of data implementation by restricting access
to accessors and mutators (getter...
Polymorphism
› Derived from two Greek words : poly which means many and
morphs, which means form.
› So, the meaning of the...
Inheritance
› The feature by which one class acquires the characteristics of an
existing class is known as Inheritance.
› ...
Inheritance Example
Inheritance Example
Inheritance Example
Inheritance
Inheritance Example
Calling Constructor of parent class
ERROR
Method Overriding
› Do you remember the previous example of ParentClass and
ChildClass?
› Did you notice a display() metho...
Returning Object
Returning Object
The final keyword
› Purposes of final keyword in Java
1. Declaring a constant variable
2. Preventing a method from being o...
Abstract Methods & Classes
› A method without a definition is known as abstract method.
› A method is declared abstract wh...
Abstract Methods & Classes Example
Interface
› An interface is a collection of various methods without definition.
› An interface is declared using interface...
Interface Example
Example
DDOOCP Practice Questions
› Describe the structure of the syntax of a Java statement that
instances an object.
› Explain t...
References
› http://codebetter.com/raymondlewallen/2005/07/19/4-major-
principles-of-object-oriented-programming/
› http:/...
Topic 03: Introduction to Object Orientation
Upcoming SlideShare
Loading in …5
×

Topic 03: Introduction to Object Orientation

2,141 views

Published on

Slides

Published in: Education
1 Comment
1 Like
Statistics
Notes
  • Find more slides related to Java in : http://www.pradipkharbuja.com.np/softwarica-college-of-it-e-commerce/ddoocp/
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
2,141
On SlideShare
0
From Embeds
0
Number of Embeds
971
Actions
Shares
0
Downloads
84
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Topic 03: Introduction to Object Orientation

  1. 1. Topic 3 : Introduction to Object Orientation DDOOCP
  2. 2. Terminologies › Encapsulation › Polymorphism › Inheritance › Method Overriding › final Keyword › Abstract class and methods › Interfaces
  3. 3. 4 major principles of OOP 1. Encapsulation 2. Abstraction 3. Polymorphism 4. Inheritance
  4. 4. Encapsulation › Encapsulation is the hiding of data implementation by restricting access to accessors and mutators (getters and setters). › Concept of encapsulation is creating the class with private attributes and public methods to interact those attributes.
  5. 5. Polymorphism › Derived from two Greek words : poly which means many and morphs, which means form. › So, the meaning of the word polymorphism is many forms. › Two types 1. Static polymorphism or early binding or compile-time polymorphism 2. Dynamic polymorphism or late binding or runtime polymorphism › Static polymorphism is obtained through method overloading. › Write examples of method overloading and constructor overloading.
  6. 6. Inheritance › The feature by which one class acquires the characteristics of an existing class is known as Inheritance. › A class that is inherited is called super class or parent class. › A class that inherits the superclass is called a sub class or child class. › The extends keyword is used in sub class to inherit a super class. › A class can extend from only one parent.
  7. 7. Inheritance Example
  8. 8. Inheritance Example
  9. 9. Inheritance Example
  10. 10. Inheritance
  11. 11. Inheritance Example
  12. 12. Calling Constructor of parent class ERROR
  13. 13. Method Overriding › Do you remember the previous example of ParentClass and ChildClass? › Did you notice a display() method in ParentClass and also in ChildClass? › The display() method in ChildClass overwrites definition of display() method of ParentClass. › This is known as Method Overriding.
  14. 14. Returning Object
  15. 15. Returning Object
  16. 16. The final keyword › Purposes of final keyword in Java 1. Declaring a constant variable 2. Preventing a method from being overridden 3. Preventing a class from being inherited. Demo
  17. 17. Abstract Methods & Classes › A method without a definition is known as abstract method. › A method is declared abstract when it needs to be overridden in its subclasses. › An abstract class is a class that has at least one abstract method. › Java allows us to define abstract methods and classes by using the abstract keyword. › An abstract class cannot be instantiated i.e. you cannot create objects of an abstract class.
  18. 18. Abstract Methods & Classes Example
  19. 19. Interface › An interface is a collection of various methods without definition. › An interface is declared using interface keyword instead of class. › An interface can be implemented by one or more class using the implements keyword. › An advantage of using interfaces is that we can implement multiple interfaces. › An interface cannot be instantiated i.e. you cannot create objects of an interface. › All the methods declared in the interface must be overridden.
  20. 20. Interface Example
  21. 21. Example
  22. 22. DDOOCP Practice Questions › Describe the structure of the syntax of a Java statement that instances an object. › Explain the terms encapsulation and polymorphism with reference to natural and manufactured real universe objects. › Describe, giving examples in Java, the purpose of the extends keyword. › Explain why the facility of inheritance, in the Java programming language, is regarded as being so very important. › Describe why the Object-Oriented paradigm is considered superior to the Structured Programming paradigm.
  23. 23. References › http://codebetter.com/raymondlewallen/2005/07/19/4-major- principles-of-object-oriented-programming/ › http://stackoverflow.com/questions/8960918/how- encapsulation-is-different-from-abstraction-as-a-object-oriented- concept-in

×