Thursday, December 4, 2014


In our real life, we deal with different informations like our name, our age, our date of birth, our height, our weight etc.
Some of the informations you need to keep private to yourself only, some informations we want to keep within a particular group of people, some we expose as public information.
For example,

public information - My name Palash Kanti Kundu
protected information - My Salary or Bank Balance, which I choose to disclose to some of the trusted people like my family members. That is, I am protecting this part of information to be public.
default information - My age, which is by default known to my parents without doing anything.
private information - I'm not going to disclose my any of personal information to anyone. Might be you have your own which you choose not to disclose to anyone.

So, what's the point here ?
I just want to draw an analogy of Java world to our real world.

So, you mean to say in our Java program we can differentiate information the same way ?
Exactly yes.

How ? Is Java that much intelligent to differentiate between information ?
Wait dear, you took this in a wrong way.
Remember, a computer does nothing except working the same way we ask to do it. Computer does nothing about what to use, when to use and how to use.

So, how information is differentiate in public, protected, default and private ? Who decides ?
It is only you who decides what when and how do deal with the data. The advanced idiot box will just follow the way you ask it to do.

Oh my god !!!
Then how robots work ?
Good question. Don't forget, robot is also a machine and it has someone else has created a brilliant solution based algorithm which is set to the robot and it behaves exactly the same way the installed program asks it to do. It is not the robot which has the brain, it is that person(that intelligent programmer) or a group of intelligent programmers who use their brain to create that device.

Well, understood. Now tell me about what you started with.
Yeah dude(gal), on the way. So, you know you have some information and you are solely responsible to device the algorithm of what information to use when and how.

Now, in your program you want to choose the way your information to be accessible.

To facilitate your requirement, Java provides you some special keywords known as modifiers.

These modifiers can be of two different flavours,
1. Access Modifiers: These modifiers are used to deal with  the access pattern of Class, Methods and Variables.
    There are four access modifiers in Java, public, protected, default and private.
2. Non Access Modifiers: These modifiers deal with the behaviour of ClassMethods and Variables.
     There are six non access modifiers in Java, final, static, abstract, synchronized, transient, volatile.

Hey hold on, let me remember what you were just discussing at first. You also mentioned these four, right ?
Yeah. So, you are getting this. Now, you are in a situation where you can understand a little bit about these access modifiers.

Just think of some scenarios, where you want to put public, private, protected and can understand which are default informations. Don't think abou the non access modifiers right now, we'll be going through them shortly.

In my next post, I will be discussing about packages and then will move into Access Modifiers.

Prev     Next
Palash Kanti Kundu

No comments:

Post a Comment