Java vs. C# access modifiers looked at by a C# programmer

I’m looking into the SCJP 6 as I don’t have hands on experience on Java projects (only academic apps).

I had bookmarked long time ago a great C# vs. Java comparison Dave Obasanjo made:

A COMPARISON OF MICROSOFT’S C# PROGRAMMING LANGUAGE TO SUN MICROSYSTEMS’ JAVA PROGRAMMING LANGUAGE



I noticed tonight that the member’s access modifiers could use some tuning and show:

C# access modifier

Java access modifier

private

private

public

public

internal

Default (package-private)

protected

N/A

internal protected

protected



In Java, a protected member can only be accessed through classes on the same package and through subclasses whether they are on the same package or not.

The protected modifier specifies that the member can only be accessed within its own package (as with package-private or default) and, in addition, by a subclass of its class in another package. Package + Kids access.

The default access modifier in Java happens when a class member has no modifier (the default is also known as package-private). This means the member is only accessible by a class defined within the package.

2 thoughts on “Java vs. C# access modifiers looked at by a C# programmer”

  1. Hi.
    The way you have differentiate between java and c# is very interesting and helpful for me in my work.Thanks for posting your article.Looking forward for more articles by you.
    Thanks a lot.

  2. As similar as the two languages are in terms of purpose, it’s important to remember that C# holds its origins in Microsoft’s desire to have a proprietary “Java-like” language of their own for the .NET framework.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.