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...

There are 2 methods in a class. Both have the same method
signature except for return types. Is this overloading or
overriding or what is it?

Answer Posted / ashish

it is overloading not overriding.
not overriding bcz two methods are in same class and
overriding is when one class extends another class and
overrides its methods.
how overloading?
see the Example:
class Ashu
{
int a,b;

int add(int x,int y)
{
int z=x+y;
return z;
}
void add(double x, double y)
{
double z=x+y;
System.out.println(z);
}
}
class Ashish
{
public static void main(String args[])
{
Ashu obj=new Ashu();
obj.add(10.7,20.9);
int a=obj.add(10,20);
System.out.println(a);
}
}

here return types are not same but parameters are same. now
in main pogram integer or double parameters in different
calls by the object account for method overloading.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the format specifier?

918


When is an object subject to garbage collection?

1053


How do you replace all in word?

1057


How do you test a method for an exception using junit?

1198


Explain java heap space and garbage collection?

1058


what is the significance of listiterator in java?

1074


What are JVM.JRE, J2EE, JNI?

1097


Is break statement can be used as labels in java?

958


Print Vertical traversal of a Binary Tree.

1010


Why we use multi threading instead of multiprocessing?

1056


Why are there no global variables in java?

1041


What is the use of a copy constructor?

985


Explain the use of volatile field modifier?

1071


How do constructors use this() and super()?

1110


Is map sorted in java?

1057