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

  • Home
  • SEARCH
  • 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 7428601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:49:44+00:00 2026-05-29T08:49:44+00:00

Learning Java I was sometimes taught to use the private access modifier so as

  • 0

Learning Java I was sometimes taught to use the private access modifier so as not to expose “sensitive information” to other classes, as if this could open a legitimate security hole. But I’ve never encountered a situation in which restricting member visibility was more than a convenience for modelling a program in an object-oriented fashion.

Are private fields and functions in Java classes actually more “secure” than otherwise?


EDIT — Compilation of best answers.

Why private does not mean “secure”:

  • decompilers allow static look at bytecode
  • reflection library allows runtime access to private members

What private is good for:

  • maintainability of code due to forcing method-level access
  • modularity of code by hiding implementation details
  • 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-05-29T08:49:44+00:00Added an answer on May 29, 2026 at 8:49 am

    I’ve never heard of it — in any serious sense — as a security issue. I mean, decompilers work. You can use them to figure out what’s going on inside the bytecode.

    Having private members is a maintainability issue. If I only give you method-level access to my internals, then my only responsibility is to ensure that my API methods continue to work. I’m not locked into using a Double versus a BigDecimal on the insides, so long as my methods continue to return Doubles (for instance).

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

Sidebar

Related Questions

Other than learning java, spring, hibernate, servlets, jsp's, how to use eclipse/netbeans, databases like
I am learning java for 3 months and sometimes i can not understand the
I am learning Java, theres one thing I do not understand.. in the main
I started learning Java. When would I use a HashMap over a TreeMap?
I am learning java. I am trying to use composite design pattern. I am
I'm learning Java here and trying to get to grips with classes and how
Well..I am learning java now and I am curious to know will this yield
I'm learning java. I was trying to run the code, where I got this
I'm still learning Java. I'm trying to get use SharedPreferences to set the url
While learning Java I stumble upon this error quite often. It goes like this:

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.