What is access modifiers?

Answer Posted / sumit pal singh

In java there are four type of access modifier.
1.private:It is accessible only within the class.
2.default:If you don't use any modifier then it is treated as default bydefault .it is accessible within package.
3.protected:The protected access modifier is accessible within package and outside the package but through inheritance only.
4.public:The public access modifier is accessible everywhere. It has the widest scope among all other modifiers.

The access Modifier in java specify the scope of data member,method,constructor and class.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between ‘>>’ and ‘>>>’ operators in java?

643


Why is flag used in java?

553


Why generics are used in java?

556


Is special character in java?

616


Why synchronization is important?

591






What is a protected void?

506


Write an algorithm for quick sort?

619


Write a program in java to calculate the difference between the sum of the odd level and even level nodes of a binary tree.

537


FOR EXAMPLE WE R HAVING TWO LIST ELEMENTS ..BOTH LISTS CONTAINS ID,NAME,PLACE ..I NEED TO COMPARE BOTH IDS IN TWO LISTS,IF ID'S R SAME MEANS WE HAVE ADD THE DETAILS(LIKE NAME,PLACE) TO MAP...HOW IS POSSIBLE ?CAN ANY ONE SUGGEST?

2643


what do you mean by marker interface in java?

547


What is navigable map in java?

527


Is there any difference between synchronized methods and synchronized statements?

586


What is functional interface in java?

517


Does string is thread-safe in java?

595


Can a main method be overloaded?

576