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

Inheritance and polymorphism

on

  • 169 views

Inheritance and polymorphic in Java

Inheritance and polymorphic in Java

Statistics

Views

Total Views
169
Views on SlideShare
169
Embed Views
0

Actions

Likes
0
Downloads
12
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Inheritance and polymorphism Inheritance and polymorphism Presentation Transcript

  • Core Java: Inheritance Team Emertxe
  • 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”)} }
  • Method Overriding Re-defining the method of parent class in the child is called method overriding
  • 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
  • Example Class Vehicle{ Public void run(){sopl(“vehicle”)} } Class Car extends Vehicle{ Public void run(){sopl(“run”)} }
  • Method Binding The association of reference variable and method is called method binding
  • Types of method Binding Static Method Binding Dynamic Method Binding
  • 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
  • Example Class Vehicle{ Public static void run(){sopl(“vehicle”)} } Class Car extends Vehicle{ Public void run(){sopl(“run”)}// compiler error }
  • Dynamic Binding Dynamic Polymorphism Dynamic binding will occur when we have Inheritance already
  • 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(); } }
  • 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
  • THANK YOU