Difference between overloading and Overriding. <Giving a
confusing example to test the concept.>
(also asked in PA Consultancy Group,iflex,Value
chain,IBM,CTS,Accenture, Tarang>

Answer Posted / kabita

overriding is only possible in case of inheritance,bt
overloading is possible incase of both inheritance & same
class.
class A
{
public int add();
public float sub();
public float multi(float a,float b){}
public double div(double d,double e){}
}
class B extends A
{
public int add(int a,int b){}//must be same as declared in
super class
public float sub(float a,float b){}//must be same name same
returntype same as declared
public float multi(float a,float b,float c){}

}

Is This Answer Correct ?    12 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different types of garbage collectors in java?

548


What is string pool in java?

566


What's the purpose of static methods and static variables?

598


Is jdk required on each machine to run a java program?

756


Explain why wait(), notify() and notifyall() methods are in object class rather than in the reading class?

563






What is difference between static and abstract class?

522


What is an exception in java?

648


What defines function?

542


What is the use of static class?

548


What is a numeric digit?

586


Define an enumeration?

615


What is the core java?

543


How do I enable java in safari?

549


What is indexof?

547


What is int argc char * argv?

569