What are different type of access modifiers?

Answer Posted / janet

Public: Any thing declared as public can be accessed from
any where.
Private: Any thing declared as private can't be seen
outside of it's class.
Protected: Any thing declared as protected can be accessed
by classes in the same package and subclasses in the other
packages.
Default modifier: can be accessed only to classes in the
same package.

Is This Answer Correct ?    11 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a file pointer?

509


what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????

1795


Give a brief description of java socket programming?

517


How do we access static members in java?

624


What is the old name of java?

499






Explain implementation and how is it different from conversion?

583


Can we define private and protected modifiers for variables in interfaces?

574


What is module with example?

507


Define array. Tell me about 2-D array.

580


Name few java 8 annotations ?

559


How do you clear a method in java?

533


I am a fresher and know core java, c languge, html, css etc if I am illegible for any job then send it on my email tatranakshay276@gmail.com

1066


Why is java multithreaded?

527


What are the restriction imposed on a static method or a static block of code?

589


Is hashset sorted in java?

656