What is the Difference between Overriding and overloading?

Answer Posted / deepika singh

OVERLOADING:- 1) overloaded methods have the same name but
different parameter list.
2)a subclass method can overload a superclass method

eg:-int add(int a, int b)
int add(float a , float b)
are overloaded methods



OVERRIDING:-
it just in inheritance and the overriding
method must hold the same name and the same signatures .
the change maybe just in behavior .


The Cat class in the following example is the subclass and
the Animal class is the superclass. The Cat class overrides
eat() method inherited from Animal class.

public class Animal {

public void eat() {
System.out.println("Eat for Animal");
}
}

public class Cat extends Animal {

public void eat() {
System.out.println("Eat for Cat");
}
}

Is This Answer Correct ?    62 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an application domain? how they get created?

589


Explain the advantage of option strict on?

537


What is non_deterministic finalization?

630


Write program in VB.Net with SQL Server and Crystal Reports to develop a small windows application to add,edit,save, search and print Employee Information and send sourcecode as zip file. empcode : .............. empname : .............. dateofjoin : dd/mm/yyyy dateofbirth : dd/mm/yyyy TableName: EmpMaster EmpCode EmpName DOB DOJ TableName: EmpDocs EmpCode DocNo DocName ExpDate

2194


What is the difference between static or dynamic assemblies?

567






What do you mean by Redim in VB.NET?

680


How many classes a dll can contain?

561


What do you mean by serialization and deserialization?

553


Explain redim keyword?

556


What are nested classes?

546


Explain the difference between int and int32?

533


What is econo-jit?

624


i have two class that contain's two methods as same name in derived class i have to call these two methods what will happen at run time ?

2246


What is enumerator?

577


What is a preprocessor directive in vb.net?

554