Inheritance and polymorphism
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
267
On Slideshare
267
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
20
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Core Java: Inheritance Team Emertxe
  • 2. Defining Inheritance  It allows creation of new object from existing  Example: Class Vehicle{ Public void run(){sopl(“vehicle”)} } Class Car extends Vehicle{ Public void run(){sopl(“run”)} }
  • 3. Method Overriding Re-defining the method of parent class in the child is called method overriding
  • 4. Rules of Method Overriding  The return type of the method will be same or the co- variant return type  Super class or Subclass type  The no of parameter of the method should be same  If the return type if exception then the overriding method will either write the same exception name as return type or child exception class name
  • 5. Example Class Vehicle{ Public void run(){sopl(“vehicle”)} } Class Car extends Vehicle{ Public void run(){sopl(“run”)} }
  • 6. Method Binding The association of reference variable and method is called method binding
  • 7. Types of method Binding Static Method Binding Dynamic Method Binding
  • 8. Static Method Binding Static binding will occur in the following situation: • When the method is static • When the method is private • When the method is final
  • 9. Example Class Vehicle{ Public static void run(){sopl(“vehicle”)} } Class Car extends Vehicle{ Public void run(){sopl(“run”)}// compiler error }
  • 10. Dynamic Binding Dynamic Polymorphism Dynamic binding will occur when we have Inheritance already
  • 11. Example Class Vehicle{ Public void run(){sopl(“vehicle”)} } Class Car extends Vehicle{ Public void run(){sopl(“run”)} Public static void main(String[] args){ Vehicle v = new Car(); V.run(); } }
  • 12. Stay connected About us: Emertxe is India’s one of the top IT finishing schools & self learning kits provider. Our primary focus is on Embedded with diversification focus on Java, Oracle and Android areas Emertxe Information Technologies, No-1, 9th Cross, 5th Main, Jayamahal Extension, Bangalore, Karnataka 560046 T: +91 80 6562 9666 E: training@emertxe.com https://www.facebook.com/Emertxe https://twitter.com/EmertxeTweet https://www.slideshare.net/EmertxeSlides
  • 13. THANK YOU