Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 19th, 2008, 06:01 AM
Authorized User
Points: 303, Level: 6
Points: 303, Level: 6 Points: 303, Level: 6 Points: 303, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: , , United Kingdom.
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Default Access modifiers private and public

Hi all, if have been reading from 2 very good sources about using access modifiers (private, public etc). Both sources directly conflict with each other.

One says
"Under no circumstances will a sub class inherit any method or instance variable if it is defined as private in a super class"

and the other source says
"Any private instance variable that has been inherited from a super class can only be accessed indirectly through public setter and getter methods in the super class. If the setters and getters in the super class are defined as private the private instance variables in the sub class will be inaccessible."

Can anyone confirm which is correct.

Many Thanks
Mark


Reply With Quote
  #2 (permalink)  
Old February 19th, 2008, 11:22 PM
jomet
Guest
 
Posts: n/a
Default

Quote:
quote:Originally posted by markhh



One says
"Under no circumstances will a sub class inherit any method or instance variable if it is defined as private in a super class"

and the other source says
"Any private instance variable that has been inherited from a super class can only be accessed indirectly through public setter and getter methods in the super class. <s> If the setters and getters in the super class are defined as private the private instance variables in the sub class will be inaccessible."</s>

both are same
except some change in strike thorough part
read as 'the super class will be inaccessible'.

if private then variables will be inaccessible in sub class.
for accessing private variables we declare public getters and setters.
Usually by using public methods we will access private variables in sub class.

Cheers,

jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
Reply With Quote
  #3 (permalink)  
Old February 19th, 2008, 11:38 PM
jomet
Guest
 
Posts: n/a
Default

hi
check the link also

http://www.uni-bonn.de/~manfear/javaprotection.php


jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
Reply With Quote
  #4 (permalink)  
Old February 21st, 2008, 04:56 AM
Authorized User
Points: 303, Level: 6
Points: 303, Level: 6 Points: 303, Level: 6 Points: 303, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: , , United Kingdom.
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Default

Many thanks for your helpful replies,

Mark

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
X509 public/private key signing and mmc ZeeKoei General .NET 1 January 23rd, 2008 03:52 AM
Friend access modifier acts as private sandeep ASP.NET 2.0 Professional 2 July 19th, 2007 07:35 AM
How to generate public and private keys using RSA mannuvashishta VS.NET 2002/2003 0 March 17th, 2007 10:52 AM
prob with certificate's public/private key shiby_chacko1@rediffmail. C# 0 April 5th, 2005 07:18 AM
event handlers declared as private or public ACE2084 ASP.NET 1.0 and 1.1 Basics 3 January 24th, 2005 12:28 PM



All times are GMT -4. The time now is 04:16 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.