:: 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 (1728)
 Advanced Java interview questions  Advanced Java Interview Questions (332)
 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 (147)
 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 ?    111 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 11 No
Ankit Porwal
# 3
this is not true in all cases. 
Is This Answer Correct ?    19 Yes 19 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
"We cannot create an object of interface but we can create a variable of it". Discuss the statement with the help of an example. (Plz help us to provide immediately.)   3
What is Collection interface? Zensar 1
What is object   6
Is it possible to write method inside method L&T 4
how to accept integer array in java   2
How to set the Heap size in Java ? HCL 2
I have a Person object with 5 variables and I want to store them in a file called Person.txt. What should I do? KPIT 3
What is file class and what is its purpose?   1
Which class is extended by all other classes?   4
How to perform Singleton of the java class object on multi JVM?   2
What is the difference between constructor and method?   4
What is the difference between panel and frame ? IBM 6
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.   ::