Showing posts with label private. Show all posts
Showing posts with label private. Show all posts

Java- public,default,private &protected modifiers for method & variables / Chapter -5/ Access Modifier

public,default,private &protected modifiers

Java public,default,private &protected modifiers



1. public members:-


If a member(variable or method) declared as public then we can access that member from anywhere.
But corresponding class should be visible or accessible so that before checking member visibility we have to check class visibility.


example:-
public,default,private &protected modifiers

public,default,private &protected modifiers


In the above example m1() method is public but we can't access from outside package corresponding class A is not public i.e. if both classes &  method are public than only we can access the method from outside package.


2.default members:-


Java- public,default,private &protected modifiers for method & variables / Chapter -5/ Access Modifier

1. public members:-
If a member(variable or method) declared as public then we can access that member from anywhere.
But corresponding class should be visible or accessible so that before checking member visibility we have to check class visibility.

example:-

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com