Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading content…
Loading…
Transcript

Java provides three types of visibility modifiers:public,private and protected.they provide different levels of protection as described below.

PRIVATE ACCESS

  • Private field enjoy the highest degree of protection.They are accessible only with their own class.

1.Public access

2.Friendly access

3.Protected access

4.Private access

5.Private protected access

  • They cannot be inherited by sub classes and therefore not accessible in subclasses.

visibility control

  • In case of overriding public methods cannot be redefined as private type.

1.It is possible to inherit all the members of a class by a subclass using the keyword EXTENDS.

2.The variables and methods of a class are visible everywhere in the program.However,it may be necessary in some situations we may want them to be not accessible.

BY:

USHA

MAHESHWARI

STELLA

MEGHANA

PRIYANKA

public access

Any variable or method is visible to the entire class in which it is defined.What if we want to make visible to all the classes outside this class?This is possible by simply declaring the variable or method as PUBLIC.

visibility control in

java

EX:

public int number;

public void sum() {.....}

A variable or method declared as PUBLIC has the widest possible visibility everywhere

3.We can achieve in this java by applying VISIBILITY modifiers to instance variables and methods.

4.The visibility modifiers are also known as ACCESS MODIFIERS

5.Acess modifiers determine the accessibility of the members of a class.

PROTECTED ACCESS

The visibility level of a "protected" field lies in between the public access and friendly access.

That is,the protected modifier makes the field visible not only to all classes and subclasses in the same package but also to subclasses in other packages.

FRIENDLY ACCESS

When no access modifier is specified,the member defaults to a limited version of public accessibility known as "friendly" level of access.

PRIVATE PROTECTED

ACCESS

The difference between the "public" and the "friendly" access is that the public modifier makes field visible in all classes,regardless of their packages while the friendly access makes field visible only in same package,but not in other packages.

  • A field can be declared with two keywords private and protected together like:

This gives a visibility level in between the "protected" access and "private" access.This modifier makes the fields visible in all subclasses regardless of what package they are in.Remember,those fields are not accessible by other classes in the same package.

Learn more about creating dynamic, engaging presentations with Prezi