constructor overloading


I am reading below link

i wonder why we need below method

String fullName() {

return Full_Name;


i also not sure how we got female as output in 2nd overloaded constructor.

Please advise
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You posted another question with a link from the same website. Myself and another expert advised you not to follow this website. It is teaching a lot of bad/wrong stuff. You will become a bad programmer if you continue to follow.
mccarlIT Business Systems Analyst / Software DeveloperCommented:
I agree with Gurpsbassi, leave this site alone.

However, the question is now in your head, and the answer is fairly simple, so...

i wonder why we need below method

You need the below method in order to access the value of Full_name from outside the class, since the field is declared "private". Typically this is just a "getter" method and so should be called something like "getFullName()" and hopefully that is what you have seen in other code and should make sense now.

i also not sure how we got female as output in 2nd overloaded constructor.

Well it's simple, "female" was what was passed into that constructor, and in that constructor, the value that is passed in is what gets assigned to the Full_Name field. So when you then, "get" the full name back out of it and print it, you get "female"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.