ALLInterview.com :: Home Page KalAajKal.com
 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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Explain the differences between public, private, protected 
and static?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Explain the differences between public, private, protected and static?
Answer
# 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 ?    26 Yes 9 No
Ranganathkini
 
  Re: Explain the differences between public, private, protected and static?
Answer
# 2
public-->inherite the protected members as preotected in 
drived class and pubic members wiull be public in derived 
class

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 ?    7 Yes 3 No
Manne Ranjith
 
 
 
  Re: Explain the differences between public, private, protected and static?
Answer
# 3
this is not true in all cases.
 
Is This Answer Correct ?    2 Yes 2 No
Quins Welfred
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
what is multithreading? Virtusa4
What are the Object and Class that classes used for?  3
How many bits are used to represent unicodde,ASCII,UTF-16 and UTF-8 characters?  2
We have two methods to create methods the threads. 1. Implementing runnable interface 2. Extending to thread class and overriding run method. Among these two which one is better and why? Please explain me in detail.  2
what is the difference between multitasking and multithreading?  8
what is finalmethod & final variable with example? HP2
What is the difference between overloading and overriding a function? Infosys7
What is meant by serialisation and deserialisation?  3
Can we instantiate Interfaces? Ericsson4
Why can't we make jsp as a controller and action servlet in struts? TCS6
How you can create a radio buttion using Checkbox class?  1
Which is not Object in Java? Honeywell7
What primitive Java types? Howmany are they and what are their names?  3
How to add panel to a Frame?  2
Can you declare a static variable in a method?  4
Can applet in different page/s communicate with each other?  1
Why do inner class cannot have static declaration except static nested class? Wipro1
What is constructor and virtual function?  4
How are this() and super() used with constructors?  4
What is the immediate superclass of Menu?  1
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com