Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8594639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:14:42+00:00 2026-06-12T00:14:42+00:00

How does the access specifiers like private, public, etc. help in code re-usability? i

  • 0

How does the access specifiers like private, public, etc. help in code re-usability?

i got this question for an interview and i were not able to find the ans. plz help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:14:43+00:00Added an answer on June 12, 2026 at 12:14 am

    There are several fine lines around this, with which I could answer the question a few different ways.

    Consider the case where a developer marks just about everything as private. It may have been a perfectly good class that could have been reused if only I could have extended it and overridden the doSomething() method. However, since the method has been marked private, my hands are tied. This will cause many developers to copy & paste the entire class, changing the one necessary part. (Not cool.) So it could be seen that marking everything as private prevents reuse.

    However, on the other hand, consider the case where a developer marks everything as public. That developer or other developers start writing extension classes, or calling all of the various methods / accessing attributes which maybe should have been marked protected / private. A design bug or such is found, which requires the class to be modified. However, since it was written so “open”, what may have been a simple fix is now much more complex, as all of the additional references have to be found and considered.

    I think the best option is a compromise. Mark things that are designed to be used by client code as “public”. Mark things that have no business being extended / overridden as “private”. If there is something that could prove useful to someone in the future to extend, mark it as “protected”. And always add Javadocs to further signal your intentions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It looks like JavaScript does not have access to authentication cookies ('ASP.NET_SessionId', '.ASPXFORMSAUTH') in
In the following code, it seems class C does not have access to A's
i need your help in access db i have a table like this ID
The following method does not access any shared variable. It is still not thread
This is a continuation of the post How does one access a method from
How does this program access other processes memory? How can it write into the
Our websites article backend does not allow access to anything above </head> which prevents
Using Python, how does one parse/access files with Linux-specific features, like ~/.mozilla/firefox/*.default ? I've
I have VS 2010 Professional (which, unlike Premium , does not include access to
How does one access a member variable when using placeholders as functors in Thrust

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.