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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:43:13+00:00 2026-06-11T18:43:13+00:00

I was comparing access modifiers in Java and C#. I wanted to find an

  • 0

I was comparing access modifiers in Java and C#. I wanted to find an alternative of C#’s protected internal in Java. But I noticed that protected modifier is different in both the languages (C# and Java). protected in Java is equivalent to protected internal of C# because the member gets accessible within the same package too.

I have two questions

  • Why have they created different meanings to same modifier in Java and C#?
  • How can I have protected of C# (Access is limited to the containing class or types derived from the containing class.) in Java?
  • 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-11T18:43:14+00:00Added an answer on June 11, 2026 at 6:43 pm

    Why have they created different meanings to same modifier in Java and
    C#?

    A choice had to be made between simplicity and the ability to precisely specify different access rights. Different choices were made by the creators of Java and (later) by the creators of C#.

    How can I have protected of C# (Access is limited to the containing
    class or types derived from the containing class.) in Java?

    You can’t. Java is more limited on this point.

    But you should probably limit your use of the protected keyword as in both use it means a breaking of the general encapsulation principle. This use is sometimes useful, as a too strict language can mean too much useless code, but beware not to make something that will be too tied and hard to change and maintain. Giving access to internal fields or methods to overriding classes often means you have an heavy hierarchy with too much implementation coupling (prefer composition over hierarchy for maintainability).

    Note that a variable or method declared without any access control modifier is available to any other class in the same package. In my opinion, that’s saner than allowing access by subclasses of any package.

    Here’s the complete grid :

    enter image description here

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

Sidebar

Related Questions

The problem is this: I have multiple competing threads (100+) that need to access
In languages like Java, you can declare a class without a modifier so it
The MS access database does not allow comparing fields with 'memo' datatypes in SQL
I am testing out RestKit and need to access different BaseUrls and also sometimes
Say I have a file with each line depicting a different command (but of
I am reading some Java text and the text says that we can only
FB.getLoginStatus returns access token and signed request . I've passed them both to server
I need to compare two objects in Java, but they contain a lot of
I am coding a class that compares the files of two directories via comparing
i'm having an issue comparing a date in an access database. basically i'm parsing

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.