• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Has-A doubt

 
Harsha Ka
Ranch Hand
Posts: 45
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi everybody.
My doubt is that does ghi has-adef .Though it does not inherit def, it can still access def through setters and getters.Please clarify it for me.
Thanks!

 
Harpreet Singh janda
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think no.
 
Prateek Parekh
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harsha Ka wrote:

Hi everybody.
My doubt is that does ghi has-adef .Though it does not inherit def, it can still access def through setters and getters.Please clarify it for me.
Thanks!



The answer is No. Since, you have declared def d as private, sub classes of ghi (abc in this case) will not have "direct" access to def. However, you can use the public setter/getter methods to access def (as per encapsulation).
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Yes through getters and setters else no.

Best Regards,
 
sumit kothalikar
Ranch Hand
Posts: 91
Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

Yes through getters and setters else no.

 
Harsha Ka
Ranch Hand
Posts: 45
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok..Thanks guyz!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic