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...


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>

Answers were Sorted based on User's Feedback



Difference between overloading and Overriding. <Giving a confusing example to test the concept...

Answer / ketan shekhawat

Overloading and Overiding are pratical implementation of OOPs Concept.

Overloading:

In Simple words, Same function name but different signature(Parameters)

For Example:

To Add 2 integers Add(int i, int j)

To add two string Add(string i, string j)

Depending on the signature(parameters) of the calling function, respective function would be called. if you pass 2 string parameter second function would be called and if you pass two integer parameter first function would be called.

Overriding(Polyphormism):

Same Function Name, same signature, different functionality.

Example for overriding

Class Shapes { Virtual void Paint() }

Class Circle:Shapes { Override void Paint() }

Class Square:Shapes { Override void Paint() }

Here in the above code we can see that the shapes is class which has a method Paint, which would paint according to the shape of the object each object would implement the paint method differently based on its dimensions.

Is This Answer Correct ?    1 Yes 0 No

Difference between overloading and Overriding. <Giving a confusing example to test the concept...

Answer / ganga

using same methodname with different signatures is known as
overloading where as
changing the definition of the parentclass in chidclass is
known as overridding.

Is This Answer Correct ?    7 Yes 9 No

Post New Answer

More Core Java Interview Questions

what is the difference b/w PUT and POST method to send data to the server

5 Answers   Mind Tree,


Can we create a constructor in abstract class?

0 Answers  


What is a get method?

0 Answers  


What makes a function well defined?

0 Answers  


What is java regex?

0 Answers  


What is null object in java?

0 Answers  


what is the difference between String s="hello"; and String s=new String("hello");?

3 Answers  


Real Time sample code for Encapsulation and Abstraction. where to use abstract and where to use specifies like public private.

2 Answers  


Mention a package that is used for linked list class in java.

0 Answers  


Is java pass by value or pass by reference?

0 Answers  


How many bits is a double?

0 Answers  


Difference between local and global transaction ?

1 Answers   Accenture, iFlex,


Categories