Object Oriented Java for testers | Ch-1 | Access Modifiers in Java

Access Modifiers are used to define the scope of classes, variables, methods or constructers.  Access Modifiers in Java are used to set the access- level of data.

There are four types of access modifiers in Java:

1. Default: Java adds a default modifier in case no access modifier is declared by the programmer.

2. Public : Can be accessed  globally across packages.

3. Private: Can be accessed  within same class only.

4. Protected: Can be accessed  via Inheritance only i.e. extending the class.

private keyword is mostly used for variables, constructors and methods not classes as a private class makes no sense.

The protected access modifier is accessible within package and outside the package but through inheritance only.

The protected access modifier can be applied on the data members, methods and constructors. It can’t be applied on the classes and interfaces.


Y- Accessible N- Not Accessible

Basic Java Tutorials:
Ch-1 | Datatypes and Variables >>> https://bit.ly/2uwnLbk
Ch-2 | Operators in Java >>> https://bit.ly/2E1fZFY
Ch-3 | Decision making >>> https://bit.ly/2GgrWNp
Ch-4 | Arrays in Java >>> https://bit.ly/2ul9Ncw
Ch-5 | Loops in Java >>> https://bit.ly/2I2Jbiu
Ch-6 | Classes and Objects in Java >>> https://bit.ly/2G8pxFm
Ch-7 | Class Constructors in Java >>> https://bit.ly/2GaSwZ5
Ch-8 |String Class in Java >>> https://bit.ly/2E0inNa
Object Oriented Java for testers | Ch-1 | Access Modifiers in Java Object Oriented Java for testers | Ch-1 | Access Modifiers in Java Reviewed by Ishan Dev Shukl on April 03, 2018 Rating: 5

No comments:

Thanks a lot for your valuable Comment!

Powered by Blogger.