What is the difference between public private, protected and static? ,Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher
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. 
 

More interview questions and answers
How do you send a message to the browser in JavaScript ?
Does JavaScript support multidimensional arrays ?
Does JavaScript support multidimensional arrays ?
Is there any tool in java that can create reports ?
What is meant by Java ?
What is meant by a class ?
What is meant by a method ?
What are the OOPS concepts in Java ?
What is meant by inheritance ? Explain with an example.
What is meant by polymorphism ? Explain with an example.
Is multiple inheritance allowed in Java ? Why ?
What is meant by Java interpreter ?
What is meant by JVM ?
What is a compilation unit ?
What is meant by identifiers ?
What are the different types of modifiers ?
What are the access modifiers in Java ?
What are the primitive data types in Java ?
What is meant by static variable and static method ?
What is meant by Garbage collection ?
What is meant by abstract class
What is meant by final class, methods and variables ?
What is meant by a resource leak ?
What is meant by a resource leak ?
What is the difference between interface and abstract class ?
What is the difference between public private, protected and static?
What is meant by method overriding ?
What is singleton class ?
What is the difference between an array and a vector ?
What is meant by constructor ?
What is meant by casting ?
What is the difference between final, finally and finalize ?
What is meant by packages ?
What are all the packages ?
Name 2 calsses you have used ?
Name 2 classes that can store arbitrary number of objects ?
What is the difference between java.applet.* and java.applet.Applet ?
What is a default package ?
What is anonymous class ?
Name interfaces without a method ?
What is the use of an interface ?
What is a serializable interface ?
How to prevent field from serialization ?
What is meant by exception ?
How can you avoid the runtime exception ?
What is the difference between throw and throws ?
Can multiple catch statements be used in exceptions ?
Is it possible to write a try within a try statement ?
What is the method to find if the object exited or not ?
What is meant by a Thread ?
What is meant by multi-threading ?
What is the 2 way of creating a thread ? Which is the best way and why?
What is the method to find if a thread is active or not ?
What are the thread-to-thread communication ?
What are the thread-to-thread communication ?
What is the difference between sleep and suspend ?
Can thread become a member of another thread ?
What is meant by deadlock ?
What is meant by deadlock ?
How can you avoid a deadlock ?
What are the three types of priority ?
What is the use of synchronizations ?
Garbage collector thread belongs to which priority ?
What is the use of ‘this’ ?
How can you find the length and capacity of a string buffer ?
How to compare two strings ?
What are the interfaces defined by Java.lang ?
What is the purpose of run-time class and system class?
What is meant by Stream and Types ?
What is the method used to clear the buffer ?
What is meant by Stream Tokenizer ?
What is serialization and de-serialisation ?
What is meant by Applet ?
How to find the host from which the Applet has originated ?
What is the life cycle of an Applet ?
How do you load an HTML page from an Applet ?
What is meant by Applet Stub Interface ?
What is meant by getCodeBase and getDocumentBase method ?
How can you call an applet from a HTML file?
What is meant by Applet Flickering ?
How to communicate between applet and an applet ?
What is meant by event handling ?
What are all the listeners in java and explain ?
What is meant by an adapter class ?
What are the types of mouse event listeners ?
What are the types of methods in mouse listeners ?
What is the difference between panel and frame ?
What is the default layout of the panel and frame ?
What is meant by controls and types ?
What is the difference between a scroll bar and a scroll panel?
What is the difference between list and choice ?
How to place a component on Windows ?
What are the different types of Layouts ?
What is meant by CardLayout ?
What is the difference between GridLayout and GridBagLayout
What is the difference between menuitem and checkboxmenu item.
What is meant by vector class, dictionary class , hash table class,and property class ?
Which class has no duplicate elements ?
What is resource bundle ?
What is meant by Swing ?