• Servlet
  • JSP
  • Spring
  • SQL Tutorial
  • Java IO
  • jQuery
  • JavaScript
  • PHP
  • RubyonRails

  • <

    Java Polymorphism Tutorial

    Polymorphism mostly used in OOP..In polymorphism object has ability to take many forms.

    Polymorphism are two types: Compile time polymorphism and Runtime polymorphism.


    Java Method Overloading


  • Method Overloading is a feature of java that a class to have more than one method having the same name.

  • A superclass variable can refer to a subclass object. This is also known as upcasting. Java uses this fact at run time.


  • Java Polymorphism Example



    class Mltply { 
     void mul(int a, int b) { 
      System.out.println("Sum of two=" + (a * b)); 
     } 
    
     void mul(int a, int b, int c) { 
      System.out.println("Sum of three=" + (a * b * c)); 
     } 
    } 
    
    class Polymorphism { 
     public static void main(String args[]) { 
      Mltply m = new Mltply(); 
      m.mul(6, 10); 
      m.mul(10, 6, 5); 
     } 
    } 
    














    © copyright 2017-2022 Completedone pvt ltd.