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 overloading in java?

Answers were Sorted based on User's Feedback



what is overloading in java?..

Answer / saurabh

it is a example of overloading:-
class Overload {
void test(int a) {
System.out.println("a: " + a);
}
void test(int a, int b) {
System.out.println("a and b: " + a + "," + b);
}
double test(double a) {
System.out.println("double a: " + a);
return a*a;
}
}
class MethodOverloading {
public static void main(String args[]) {
Overload overload = new Overload();
double result;
overload.test(10);
overload.test(10, 20);
result = overload.test(5.5);
System.out.println("Result : " + result);
}
}

Is This Answer Correct ?    2 Yes 0 No

what is overloading in java?..

Answer / binod kumar

IF WE HAVE SAME METHOD NAME WITH DIFFERENT TYPES OF PARAMETERS THEN IT IS KNOWN AS METHOD OVERLOADING.
EXAMPLE----------->

class A
{
void sum(int a,int b)

{
int s=a+b;
System.out.println("Sum of a+b is:" +s);

}
void sum(int x,int y,int z)
{
int s2=x+y+z;
System.out.println("Sum of x+y+z is:" +s2);

}
}

class ovrloading
{

public static void main(String str[])

{
A a=new A();
a.sum(10,20);
a.sum(10,20,30);
}
}
IN GIVEN EXAMPLE WE HAVE SUM METHOD WITH DIFF PARAMETERS.
OUTOUT WILL BE------->
Sum of a+b is: 30
Sum of x+y+z is: 60

Is This Answer Correct ?    0 Yes 0 No

what is overloading in java?..

Answer / sagar

i think partial operator overloading is possible in java

Is This Answer Correct ?    4 Yes 8 No

Post New Answer

More Core Java Interview Questions

What is the primitive type byte?

0 Answers  


What is the base class in java from which all classes are derived?

0 Answers  


What is a container in a gui?

0 Answers  


What are the 4 types of characters?

0 Answers  


how do I create a runnable with inheritance? : Java thread

0 Answers  


What are the advantages of encapsulation in java?

0 Answers  


How does hashset work in java?

0 Answers  


If there is no implementation of MARKER INTERFACE in java. Then how compiler come to know about specification.

2 Answers  


what is a green thread? : Java thread

0 Answers  


How a string is stored in memory?

0 Answers  


Why is java called the platform independent programming language?

0 Answers  


What are different type of exceptions in java?

0 Answers  


Categories