Share this post on:

Overloading : In Java Overloading is a Process where a class Contains multiple implementation of methods or constructor by differentiating there no of arguments or types of arguments.

public class TestDemo
{
public void disp(String c)
{
System.out.println(c);
}
public void disp(String c, int n)
{
    System.out.println(c+" "+n);
}   }
class Sample
{

public static void main(String[] args) 
{
    // TODO Auto-generated method stub  
    TestDemo obj=new TestDemo();
    obj.disp("a");
    obj.disp("a",2);
}}

Overriding : Here Methods can be over riding. It must be happen within two class. One is parent & another is child. In this parent class’s method with same name and signature.

public class TestDemo
{
public void eat()
{
System.out.println("Human is Eating");
}
}
class Overriding extends TestDemo
{
public void eat()
{
System.out.println("Human is Eating");
}
public static void main(String[] args)
{
Overriding obj=new Overriding();
obj.eat();
}
}

Here is the all the definition with example of overloading and overriding in Java.

Share this post on:
Avatar Raiyan

Author: Raiyan

Hi, I guess you're here because you want to know a bit about me. huh? I am not so good on talking about myself but I'll give a short about me.

My Name is Raiyan. I am a Professional Application Developer and a Blogger.
I started this website to Share my Knowledge. Here I provide all my knowledge whatever I earned till now.

2 Comments

  1. Pingback: Final Keyword in Java - ArzaTechs

Leave a Reply to Sneha Cancel reply

Your email address will not be published. Required fields are marked *