class A
{
public void disp(int a,int b)
{
System.out.println("hai");
}
}
class B
{
public void disp(int a,int b,int c)
{
System.out.println("hai");
}
}

above program is overloading or overriding?

Answer Posted / pravallika

There is no relation between both the classes,so it is neither
overloading nor overriding.overloading and overriding means IS-A Relationship must be there in both the classes.
for ex:

class A
{
public void disp(int a,int b)
{
System.out.println("hai");
}
}
class B extends A
{
public void disp(int a,int b,int c)
{
System.out.println("hai");
}

}
the above program is overloading,because Is-A Relationship is available in both the classes.

Is This Answer Correct ?    11 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you write a loop indefinitely in java programming?

554


What checkbox method allows you to tell if a checkbox is checked?

540


Can you explain the cs option of java interpreter?

506


How does the java compiler work?

530


What are the parts of a method?

538






What is string and its types?

613


What’s the difference between applets and standalone program?

534


What is return in java?

560


What are "methods" and "fields"?

577


What is the purpose of encapsulation?

544


Why char array is favored over string for the storage of passwords?

556


Why doesn't the java library use a randomized version of quicksort?

548


What are the data types supported by java?

550


What is string length in java?

495


What initialize variables?

505