Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


what is overloading and overriding with example?

Answers were Sorted based on User's Feedback



what is overloading and overriding with example?..

Answer / sujanya

Overloading means two methods have the same method name and
different argument list.
For example, take the case of a Shape Class where you have
a method with the name DrawShape();
This method has two definitins with different parameters.



1. public void DrawShape(int x1, int y1,int x2,int y2)
{
// draw a rectangle.
}

2. public void DrawShape(int x1,int y1)
{

// draw aline.
}
overriding means i have a super class and sub class,sub
class extends the super class.Two classes containg the same
method name and same arguments sub class overides the super
class method ,this is nothing but method overriding
for example
Class Rectangle
{

publc void DrawRectangle()
{
// this method will draw a rectangle.
}

}


Class RoundRectangle : Rectanlge
{

public void DrawRectangle()
{

//Here the DrawRectangle() method is overridden in the
// derived class to draw a specific implementation to the
//derived class, i.e to draw a rectangle with rounded
corner.

}
}

Is This Answer Correct ?    48 Yes 16 No

what is overloading and overriding with example?..

Answer / rajesh r

OVERLOADING MEANS SAME METHOD NAME WITH DIFFERENT
PARAMETERS.
BOTH SHOULD BE DEFINED IN SAME CLASS ITSELF.

OVERRIDING MEANS SAME METHOD NAME WITH SAME PARAMETERS.THIS
CAN ASSOCIATED IN A CLASS AND ITS SUBCLASS.(VIRTUAL,
OVERRIDE)

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More Core Java Interview Questions

what is the difference between a java object reference and c++ pointer?

4 Answers  


what are the different non-access specifiers in java?

5 Answers  


Difference between Encapsulation and Abstraction

4 Answers   Fidelity,


What is JDBC Driver interface?How can you retrieve data from the ResultSet

0 Answers   CTS,


Explain the inheritance?

0 Answers  


What Is Query Throttling in java?

0 Answers   HCL,


What is variable and its types?

0 Answers  


How do you compare two objects?

0 Answers  


What is array and arraylist in java?

0 Answers  


What is a functional interface?

0 Answers  


Java Compiler is stored in JDK, JRE or JVM?

0 Answers  


What are the characteristics of Final,Finally and Finalize keywords.

0 Answers   Flextronics,


Categories