what is overloading in java?

Answers were Sorted based on User's Feedback



what is overloading in java?..

Answer / narendher sharma

Methodoverloading occurs with in the class..

Methodoverloading will not involve in Inheritance ..

Method overloading means whic is same method name with
different arguments and parameters may be same may not be
same..



Methodoverloading is call as Compiletime polymorphism which
refers as static polymarphism..

Is This Answer Correct ?    76 Yes 15 No

what is overloading in java?..

Answer / ak

Overloading is when the same method or operator can be used
on many different types of data.

For instance the + sign is used to add ints as well as
concatenate strings. The plus sign behaves differently
depending on the type of its arguments. Therefore the plus
sign is inherently overloaded.

Methods can be overloaded as well..same method with
different parameters is said to be method overloading.----
we can perform the similar operation in different ways for
different parameters.

Constructors can be overloaded as well...Overloaded
constructors provide multiple ways to initialize a new object

Is This Answer Correct ?    69 Yes 12 No

what is overloading in java?..

Answer / irshad ahmad

Method overloading in java:
create more than one methods that have same name, but
different parameter lists and different definitions, within
a class.
It is used when objects are required to performed similar
tasks but with using different input parameter list.

class ABC
{
int x,y,z;
void star(int a,int b,int c)
{
x=a; y=b;z=c;
}
void star(int a,int b)
{
x=a; y= z=b;
}
void star(int a)
{
x= y= z= a;
}

int result()
{
return(x*y*z);
}
}

Is This Answer Correct ?    43 Yes 18 No

what is overloading in java?..

Answer / vijayakumar chinnasamy

Method overloading:
More than one method have same name but different type
of argument or differnt no. of arguments available in same
class or it subclass is called overloading.

Return type of method and access specifier of method is
not a problem in method overloading.

class A{
void diaplay(int a,int b){ }
void display(float a,float b){ }
void display(float a, int b){ }
void display(int a,int b){
void display(){ }

}

Is This Answer Correct ?    46 Yes 22 No

what is overloading in java?..

Answer / srujana

To define one or more methods within the same class that
share the same name, as long as thier parameters
declarations are diffrent.These methods are called
overloaded and its process is called Methodoverloading.
For example,
class Demo
{
void test()
{
System.out.println("No parameters");
}
void test(int a)
{
System.out.println("a is:"+a);
}
void test(int a, int b)
{
System.out.println("a is:"+a "," +b);
}
}
class Demo1
{
public static void main(String args[])
{
Demo1 d=new Demo();
d.test();
d.test(5);
d.test(2,3);
}
}

Is This Answer Correct ?    27 Yes 9 No

what is overloading in java?..

Answer / sivaprasad addepalli

Method Overloading comes into picture when there are two
methods with same name but it must differ in one of the
follwing:

--> Number of arguments.
--> Datatype of arguments.
--> Order of the arguments.

for ex:

class sample
{
public:

void add (int a, int b)
{
}
void add (int a, int b, int c)
{
}
}

In this case the number of arguments are different so it is
method overloading.

Is This Answer Correct ?    20 Yes 3 No

what is overloading in java?..

Answer / manohar

My question is where and what exactly does overloading does.
instead of taking risk we can use different names for
methods right.so,that we do not have any confusion, because
if we have to call overloaded methods from main method then
definetly we have to call every method with different
parameter again which is performance issue. So can you
please provide me the exact answer for this provided
examples if any one has.

Is This Answer Correct ?    13 Yes 3 No

what is overloading in java?..

Answer / dev yadav

same class two metheod & different parameters....

Is This Answer Correct ?    15 Yes 5 No

what is overloading in java?..

Answer / rajesh bonepalli

Overloading in java means creating the methods by same
method signature(name,return type) passing different
arguments/parameters.

Example :
public class Children {
public void getHabits(int k){
System.out.println("overriding in the children with
childrens behaviour int");
}
public void getHabits(){
System.out.println("overriding in the children with
childrens behaviour");
}
public void getHabits(double j){
System.out.println("overriding in the children with
childrens behaviour double");
}
public String getHabits(double j,double i){
System.out.println("overriding in the children with
childrens behaviour double");
return null;
}

}

Is This Answer Correct ?    7 Yes 1 No

what is overloading in java?..

Answer / jephin daviss

Overloading means that the same operator, method maybe used
for different purposes.
It is part of the OOP concept 'Polymorphism'.
1)Method overloading:Methods with same name, but different
argument types and number of arguments.
2)Operator overloading: Same operator can be used for
different ways, ex:'+' can be used for addition and for
concatenation.
3)Constructor overloading: We can define two constructors
for a same class, ie with same name, but difference in
argument types and number of arguments.

Is This Answer Correct ?    10 Yes 7 No

Post New Answer

More Core Java Interview Questions

Why do we use return statement?

0 Answers  


why Java does not support multiple inheritances?

0 Answers   Aspire,


diffrence b\w println() and printf()

8 Answers   NIIT,


Why synchronization is important?

0 Answers  


what is nested class in java?

0 Answers   IBS,






java is puerly object oriented or not ?

5 Answers  


Is it necessary that each try block must be followed by a catch block?

0 Answers  


What are thread groups?

0 Answers  


What is the difference between superclass and subclass?

0 Answers  


Does garbage collection guarantee that a program will not run out of memory?

1 Answers  


What is a constructor overloading in java?

0 Answers  


Difference between a process and a program?

0 Answers   Infosys,


Categories