I have searched books read through website but cannot get a justified answer. whats is the proper meaning of composition and how we attain has-a-relationship in the program.
Composition:
A composition in literal terms means " using of objects within other objects" like small pieces form a bigger entity.
In programming world, We say a programme is composed of different modules and parts.
let me give you a simple example.
A car has many parts, engine, doors, breaks, headlights etc, Now in a object oriented language, Car would be a separate Object, within it Engine, Doors , Breaks ... will be used to make a car functioning.
Has-A-relation
Now coming to the second part of your question. Has a relationship can be understood by the above example itself.
I will say, Car has-a-engine, Car has-headlight etc. Mobile phone has a screen
So Engine, Headlight and Screen are objects being used in Car and Mobile respectively.
Hope that answers the question. I would advice you to read Head First Java book to learn java step by step. And remember these things are to be related with the world and get more clarity of what they mean.