Hi dinesh,
I think the code is working fine !!!
You get first "hi" since you have invoked X's constructor...agreed?
You get second "hi" since you have again invoked X's constructor...agreed?
check that irrespective of what String you send to X's constructor, it will only print "hi"
I think that solves your problem,rest you know!
good luck !!!