Science, asked by aryan1021, 1 year ago

what are the causes of overloading

Answers

Answered by RUDEGIRL
3

In simple terms overloading can be defined as ‘-what we get is what we give’. There are three type of overloading-

1.Method overloading

2. Constructor overloading

3.Operator overloading

Method Overloading

Method overloading is when we define more than one method with same name but with different argument list.There are two ways through which we can differ the argument list-

Type of argument

number of argument

lets take an example-

class Try

{

void display()

{

System.out.println(“ no arg method”);

}

void display( int a)

{

System.out.println(“ one arg method”);

}

void display( int a,int b)

{

System.out.println(“two arg method”);

}

public static void main(String[] argus)

{

Try t=new Try();

t.display();

t.display(10);

}

}

output is -

no arg method

one arg method

Constructor Overloading

when we declare more than one time a constructor within the same class that is known as constructor overloading in Java.

class Add

{

Add(int x, int y)

{

int c=x+y;

System.out.println(c); // In this statement the number of argument are different//

}

Add(int x,int y,int z)

{

int c =x+y+z;

System.out.println(c);

}

public static void main(String[] argus)

{

Add ad=new Add(10,20);

Add ad1=new Add(10,20,30);

}

}

output-:

30

60


manannarang1313: phele ap usee
manannarang1313: pucho
manannarang1313: I will
manannarang1313: not
manannarang1313: meri respect chali gai
manannarang1313: uska kya
manannarang1313: she is online
Answered by apparagarwal789
3

Overloading is caused when too many appliances are switched on at the same time or when large amount of current is drawn from small socket.


Hope this will help you...

Similar questions