wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Has-A doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Has-A doubt" Watch "Has-A doubt" New topic
Author

Has-A doubt

Harsha Ka
Ranch Hand

Joined: Mar 14, 2010
Posts: 45



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!


SCJP 1.6,Preparing (Tryin to prepare) for scwcd
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

I think no.
Prateek Parekh
Ranch Hand

Joined: Apr 17, 2010
Posts: 34
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

Joined: Oct 13, 2009
Posts: 774
Hi,

Yes through getters and setters else no.

Best Regards,


Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
sumit kothalikar
Ranch Hand

Joined: Apr 15, 2010
Posts: 91

hi

Yes through getters and setters else no.


Thanks & Regards
Sumit Kothalikar
Harsha Ka
Ranch Hand

Joined: Mar 14, 2010
Posts: 45

ok..Thanks guyz!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Has-A doubt
 
Similar Threads
Doubt
Struts2 POJO population from URL
Non-public Outer Class Versus Static Inner Class
String.split( ) very confusing !!!!!
doubt on top level nested classes -from velumurugan periyasmays site