What is the purpose of having the concept of overloading?

Answer Posted / sridharan

Consider if u have a string and u want to find the length
of a string, so u have
getLength(String name) method which will return the length
of the string. Also if u feels that u want to find the
length of a string from the specified position or
character. So we can have same name but with one more
parameter to specify the character position. So we will
have getLength(String name, int a)

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we use return in constructor?

483


What is return code?

551


What are synchronized methods and synchronized statements in java programming?

564


Which variable is the independent variable?

527


Is vector ordered in java?

529






What does file separator do in java?

527


What is api in java?

527


What is the use of set in java?

604


What are accessor methods in java?

546


how we can create packages in java?

509


Is java a pure object oriented language?

534


What is data string?

487


What is assembly used for?

493


How can we use primitive data types as objects?

550


Difference between ‘is-a’ and ‘has-a’ relationship in java?

533