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                      
tip   To Refer this Site to Your Friends   Click 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
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 ?    55 Yes 4 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 ?    10 Yes 41 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 ?    43 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 ?    22 Yes 2 No
Ravikiran
 
  Re: can we declare private class in java file?
Answer
# 5
Can any one give example?
 
Is This Answer Correct ?    0 Yes 0 No
Hanumanth
 
  Re: can we declare private class in java file?
Answer
# 6
yes,but it is declare to inner class,not to outter class.if we are declaring "private" to outter class nothing can be accessaed from that outter class to inner class.
 
Is This Answer Correct ?    0 Yes 0 No
Prasanthi
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
what is difference between validation.xml & validation rules.xml? BirlaSoft5
What is the protocol is used in type4 driver? CMC2
jdbc drivers? Wipro7
how session will be expired? Infosys4
What is an enumeration class?  2
Write program to print Hello World and print each character address in that string and print how many times each character is in that string? Ex: H: 0 & 1 e:1 & 1 l :2,3,8 & 3 o:4,6 & 2 w:5 & 1 r: 7 & 1 d 9 & 1 Huawei3
To set the position and size of a component, which methods are used?  2
Why we use static and synchronized in method for single thread model example: public static synchronized add(){}  1
What is the exact difference in between Unicast and Multicast object ? Accenture1
How many statements can be created with one connection in jdbc? Polaris2
what is Assertion? Wipro2
if two references are having same hash codes,is that means those are refering to same object? CTS4
what is the difference between the "protected and default" modifiers?  4
Hi friends, i am new to java. can you explain how java is secured.  1
Is there is any error if you have multiple main methods in the same class? Wipro9
can we create object for static class in java Marlabs5
What modifiers can be used with a local inner class?  2
Program to output as below formate: 1 2 3 4 5 6 7 8 9 10 Huawei2
What are wrapped classes?  6
Hi Friends, I am new to java. Can u explain about thread concept.How i know one thread is locked, and how can i force or acquire another thread for lock . Finally how to know thread is released from lock. Explain types of lock(like method level and block level) in thread.  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