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

How do you sort arrays in java?

696


What are operators and its types?

809


Can you explain inner class.

817


What is a text string?

846


What is an accessor?

1310


Which keyword specify that a variable is effectively final ?

755


How do you override a method in java?

732


What is the java reflection api? Why it’s so important to have?

739


Why is java not 100% pure oops?

808


Is nullpointerexception checked or unchecked?

758


What are java methods?

787


When is the finalize() called? What is the purpose of finalization?

810


What is use of super keyword in java?

794


What is abstract class constructor called?

787


How to perform linear search in java?

739