Topics
Published on April 19, 2017 by kudvenkat
Want create site? Find Free WordPress Themes and plugins.

In this tutorial, we will discuss about classes and objects in object oriented programming language Java. We will learn the syntax of class declaration and dive deep into access modifiers in Java.

As the name suggests access modifiers in Java helps to restrict the scope of a class, constructor , variable , method or data member.

There are four types of access modifiers available in java:

Default – No keyword required
Private
Protected
Public

A private member is only accessible within the same class as it is declared.

A member with no access modifier is only accessible within classes in the same package.

A protected member is accessible within all classes in the same package and within subclasses in other packages.

A public member is accessible to all classes (unless it resides in a module that does not export the package it is declared in).

We will also discuss nested class in this tutorial
A nested class is a member of its enclosing class. Non-static nested classes (inner classes) have access to other members of the enclosing class, even if they are declared private. Static nested classes do not have access to other members of the enclosing class.

Did you find apk for android? You can find new Free Android Games and apps.

Leave a Reply

7 Comments on "Access modifiers in Java"

Notify of
avatar

Sridhar Babu
Guest
Sridhar Babu
2 months 4 days ago

Nice, add more samples for Access Modifiers

Shaswat
Guest
Shaswat
2 months 23 days ago

"Access modifiers in Java" but you are explaining something different..

Shuli Men
Guest
Shuli Men
4 months 23 days ago

the code is too blur to read

Albshr77
Guest
Albshr77
4 months 26 days ago

Thank you

RAQIBUL ALAM RASHED
Guest
RAQIBUL ALAM RASHED
5 months 12 hours ago

Thanks from Bangladesh.

dinarac777
Guest
dinarac777
5 months 13 hours ago

Very bad video. Not for beginners. Learn from Derek Banas or Cave of programming. This is losing time

Yogeshwar Goswami
Guest
Yogeshwar Goswami
5 months 21 hours ago

Please upload SSRS videos of .Net

wpDiscuz