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 / ketan gambhir
Overloading:-in overloading,we can use same name of method
and constructor with different parameters in same class.
For Exa:-
\\Both methods has different declaration and definition.
class A
{
public int same(int a int b)
{
return a+b;
}
public void same()
{
System.out.println("ketan");
}
}
Overriding:-In overriding,we can use same method and
constructor with same parameters in different classes.
For Exp:-
class A
{
public void same()
{
System.out.println("same1");
}
}
class B
{
public void same()
{
System.out.println("ketan");
}
}
Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
Explain the private protected method modifier?
Why is it important to initialize a variable?
What methodology can be utilized to link to a database?
Where are global variables stored?
Describe the Big-O Notation.
What is the difference between the font and fontmetrics classes in java programming?
What are the methods available in a class?
What is difference between static and final?
What is thread safe in java?
Explain 5 features introduced in jdk 1.7?
List out benefits of object oriented programming language?
Difference between linkedlist and arraylist.
Is main an identifier?
Explain the difference between an Interface and an Abstract class?
What is the integer of 16?