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 4083176
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:16:48+00:00 2026-05-20T18:16:48+00:00

Possible Duplicate: Why is there no sub-class visibility modifier in Java? The access level

  • 0

Possible Duplicate:
Why is there no sub-class visibility modifier in Java?

The access level table for Java, shows 4 different options for controlling access to members of a class:

Modifier    Class  Package Subclass World
public      Y      Y       Y        Y
protected   Y      Y       Y        N
no modifier Y      Y       N        N
private     Y      N       N        N

There is no modifier, however, for “accessible to class and subclass only”. That is:

Modifier    Class  Package Subclass World
c++prot     Y      N       Y        N

Is it possible at all to define such access level in Java?

If so, how?

If this isn’t possible, this must be due to a well thought design principle. If so, what is that principle. In other words, why having such access level in Java isn’t a good idea?

  • 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-20T18:16:48+00:00Added an answer on May 20, 2026 at 6:16 pm

    The design principle is that developers do not maliciously hack their own programs. If you don’t trust classes in the same package to behave correctly you have serious non-technical issues IMHO.

    The access modifiers are there to restrict accidental errors, and they attempt to stop most error with minimum complexity.

    BTW: with reflection/JNI calls you can bypass all access modifiers, so they are not a rock solid security measure IMHO.

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

Sidebar

Related Questions

Possible Duplicate: Is there a difference between single and double quotes in Java? I've
Possible Duplicate: how to provide a swap function for my class? There are some
Possible Duplicate: Is there any way to clone a git repository’s sub-directory only? clone
Possible Duplicate: Is there a way to embed a browser in Java? I am
Possible Duplicate: Is there a way to call an object's base class method that's
Possible Duplicate: Is there a proved mouseOver workaround for FirefoxDriver in Selenium2? I want
Possible Duplicate: Is there any hash function in PL/SQL? I have a column with
Possible Duplicate: Is there a way of drawing a caption box in matplotlib Is
Possible Duplicate: Is there a CSS parent selector? CSS selector for “foo that contains
Possible Duplicate: Is there any working memory profiler for Python3 I have some script

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.