0
PRIVATE -it can be accessible only on which class it exits..for example declare variables in A class with private and create another class called B and print those variables declared in class A over here in class B..you will find undefined variable .the same case exists for method too.. whereas for constructor you have to create the instance on the same class..you cannot create outside of that class which not containing constructor private. PROTECTED -You can access those members in the same program of same package..you can import them over to another program..but the methods,varibles can be accessible of different classes in ur program. A CLASS CANNOT BE DECLARED AS PROTECTED OR PRIVATE.. only possible in the nesting of classes.. PUBLIC -Csn be accessible anywhere by importing the package of current one..I mean which you DECLARED them as Public.. DEFAULT -With no access modifier defined is called default..you can access only on the same package...you can access them alover the same program of same package..out of another program or package you cannot access.
31st Jul 2016, 10:46 AM
Manikanth Vanka
Manikanth Vanka - avatar