Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is difference between method overloading & method
overridding with example?

Answer Posted / sirisha

overridding:
same method name and same signature.
import java.io.*;
class sum
{
int a=10,b=15;
void sum()
{
int sum=a+b;
System.out.println("sum is:"+sum);
}
}
class sum1 extends sum
{
int c=20;
void sum()
{
int sum1=a+b+c;
System.out.println("sum1 is:"+sum1);
}
}
class override{
public static void main(String[] arg){
sum s=new sum();
s.sum();
sum1 s1=new sum1();
s1.sum();
}
}

over loading:
method name same but different signature.
class sum{
void add(int a,int b){
}
class sum{
void add(string s1,string s2){
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What programs use java?

928


Is java a digit method?

977


Mention the default values of all the elements of an array defined as an instance variable.

965


Difference between string, stringbuffer and stringbuilder?

1010


What is a numeric format?

1070


How can we find the sum of two linked lists using stack in java?

1118


Difference between process and thread?

1013


What is consumer interface?

978


How to split a string in java?

1109


What do you know about the garbage collector?

1089


What is singleton class in ruby?

993


What is annotation in java?

1029


Can list be final in java?

904


What is string substring?

1153


Can we use static class instead of singleton?

1038