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   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
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
can we declare private class in java file?
 Question Submitted By :: Sushil
I also faced this Question!!     Rank Answer Posted By  
 
  Re: can we declare private class in java file?
Answer
# 1
A class can be marked by the "private" access specifier only
if its a nested member of another class.

Top level classes cannot be marked as "private". Hence you
can have private classes in a java file but they must be
nested inside another class.
 
Is This Answer Correct ?    6 Yes 1 No
Ranganathkini
 
  Re: can we declare private class in java file?
Answer
# 2
yes we can declare private class in java file
 
Is This Answer Correct ?    2 Yes 3 No
Varsha Vilas Kalebag
 
 
 
  Re: can we declare private class in java file?
Answer
# 3
•Only nested classes can be private. If a top-level class 
were private, nothing could access it.

So, private nested classes are just like other private 
members (methods and variables)--they can only be 
accessed "within the body of the top level class  that 
encloses the declaration of the member or constructor" 

Private classes are to be used only by their declaring 
class (more or less) just like other private members
 
Is This Answer Correct ?    5 Yes 0 No
Manoj Purohit
 
  Re: can we declare private class in java file?
Answer
# 4
No for the outer class and we can declare it for the inner 
class.
 
Is This Answer Correct ?    2 Yes 0 No
Ravikiran
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
How to access a variable if it is declared as private?  2
What is Overriding and how can it be used? Wipro2
Is multiple inheritance allowed in Java? Why ?  5
Which class is the immediate superclass of the Container class?  1
what is a transient variable?  2
What is the use of an interface?  3
What is operator?  1
Name the class that used to read objects directly from a stream? Wipro2
what is the use of finalize()Method please explain with an example  1
How many bits are used to represent unicodde,ASCII,UTF-16 and UTF-8 characters?  2
Different types of Layouts?  3
Difference between Superclass and Subclass?  2
Explain, why the constructor is required in implemented class?  2
What is exception and error? and what is the difference between them?  2
Name the methods that used to get and set the text label displayed by a Buttonobject?  1
explain me with a code snippet about the generation and handling of null point exceptions.  1
for what purpose we use applets ? Mindlogicx2
Why null interfaces are used in Java?  2
What is a method ?  2
What is a stream? what are the different types and classes of Streams?  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
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

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