:: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Categories >> Software >> Java Related >> Java J2EE >> Core Java


 Core Java interview questions  Core Java Interview Questions (1721)
 Advanced Java interview questions  Advanced Java Interview Questions (331)
 Swing interview questions  Swing Interview Questions (44)
 EJB interview questions  EJB Interview Questions (134)
 Servlets interview questions  Servlets Interview Questions (255)
 Struts interview questions  Struts Interview Questions (196)
 JDBC interview questions  JDBC Interview Questions (187)
 JMS interview questions  JMS Interview Questions (9)
 SunOne interview questions  SunOne Interview Questions (3)
 J2EE interview questions  J2EE Interview Questions (71)
 Weblogic interview questions  Weblogic Interview Questions (146)
 Websphere interview questions  Websphere Interview Questions (14)
 Java Networking interview questions  Java Networking Interview Questions (20)
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions (87)
Explain the differences between public, private, protected 
and static?
 Question Submitted By :: Core-Java
I also faced this Question!!     Answer Posted By  
# 1
Members marked public are accessible to members of any class
irrespective of the package.

Members marked private are only accessible to other members
of the same class.

Members marked protected are only accessible to other
members of the same class, members of a subclass and members
of other classes in the same package.

Member marked static are shared by all instances of that
class and hence r not related to any specific instance of
that class. Methods marked static cannot access non-static
members or fields of that class. But non-static members can
access static fields or methods.
Is This Answer Correct ?    110 Yes 21 No
# 2
public: ♫
a method or field defined by public is accessible by all
other methods and fields of that program anywhere.
private: ♫
u can't access the private members or methods outside the
class they are only accessible inside the class.
eg: if u have ";" and another file in
the package ";".
in this case u can't access the private methods of
class in the file's calsses.
protected: ♫
in case of protected u can access the protected members in
the same package but can't access outside that package.
eg: means u can access members of in
b'coz they are in the same directory.
but not accessible in iitk directories files.
for more detail contact me at
Is This Answer Correct ?    24 Yes 10 No
Ankit Porwal
# 3
this is not true in all cases. 
Is This Answer Correct ?    19 Yes 18 No
Quins Welfred
# 4
public-->inherite the protected members as preotected in
drived class and pubic members wiull be public in derived

protected--->pubic and protecated members of the base class
will become protected in derived class

Private-->pubilc and proteacted members will become private
in derived class

static--->Method is defined by static cannot access non-static
members or fields of that class. But non-static members can
access static fields or methods.
Is This Answer Correct ?    28 Yes 32 No
Manne Ranjith

Other Core Java Interview Questions
  Question Asked @ Answers
how to print the below in java?thanks in advance.... * * * * * * * *   3
What is meant by Java ? CMC 2
what happens when we add the objects morethan the size limit to a hashmap   1
how to make a un-checked exception as a checked exception one.   2
where lives in jvm   5
where to use join method and explain with real time senario?and programatical explenation also.. TCS 1
How does marker interface provides functionality to the implemented class ? or How dose maker interface gets the functionalities as serialization or cloning. Cap-Gemini 4
what are the analysis of an object   2
Why sleep()is in Thread and wait() in Object class? Why can't I have both in one class or vice versa?   1
what is the purpose of class "Object" which is base class for all classes?   3
What Method and class used for Connection pooling ? Wipro 5
I want to know the host name and provider name for tcs web mail TCS 5
For more Core Java Interview Questions Click Here 

Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
Copyright 2013  All Rights Reserved.   ::