What is the difference between public private, protected and static?

What is the difference between public private, protected and static?

1) The scope of the private members is anywhere within the class.
 
2) The scope of the protected members is anywhere with in the same package and only subclass of the different package.
3) The scope of the public members is anywhere!.

static members are Common across all objects
Also called class variable.A static variable cannot access instance method. 
 

By:Sumit Tripathi
Date:2020-05-15 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher