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
what is inner class?
 Question Submitted By :: Sushil
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is inner class?
Answer
# 1
An inner class is a class that is defined within the
definition of another class but outside any member
definition. Inner classes shud not be marked static.

An Inner class cannot be instantiated directly, i.e. one can
only instantiate an inner class by first instantiating the
outer class.

The Inner class has access to all the static as well as
non-static public/protected/private fields of its enclosing
outer class.

Inner classes are used to provide implementation that are
intimately connected with the enclosing outer class.
 
Is This Answer Correct ?    8 Yes 0 No
Ranganathkini
 
  Re: what is inner class?
Answer
# 2
Inner classes nest within other classes. A normal class is 
a direct member of a package, a top-level class. Inner 
classes, which became available with Java 1.1, come in four 
flavors: 
?	Static member classes 
?	Member classes 
?	Local classes 
?	Anonymous classes 
Let's take a quick look at each in turn. 
Briefly, a static member class is a static member of a 
class. Like any other static method, a static member class 
has access to all static methods of the parent, or top-
level, class. 
Like a static member class, a member class is also defined 
as a member of a class. Unlike the static variety, the 
member class is instance specific and has access to any and 
all methods and members, even the parent's this reference. 
Local classes are declared within a block of code and are 
visible only within that block, just as any other method 
variable. 
Finally, an anonymous class is a local class that has no 
name.
 
Is This Answer Correct ?    1 Yes 1 No
Harish
 
 
 
  Re: what is inner class?
Answer
# 3
inner classes has right to excess members of outer classes
 
Is This Answer Correct ?    1 Yes 0 No
Varsha Vilas Kalebag
 
  Re: what is inner class?
Answer
# 4
Inner classes->	Nested top-level classes, Member classes,
Local classes, Anonymous classes

Nested top-level classes- If you declare a class within a
class and specify the static modifier, the compiler treats
the class just like any other top-level class.
Any class outside the declaring class accesses the nested
class with the declaring class name acting similarly to a
package. eg, outer.inner. Top-level inner classes implicitly
have access only to static variables.There can also be inner
interfaces. All of these are of the nested top-level variety.

Member classes - Member inner classes are just like other
member methods and member variables and access to the member
class is restricted, just like methods and variables. This
means a public member class acts similarly to a nested
top-level class. The primary difference between member
classes and nested top-level classes is that member classes
have access to the specific instance of the enclosing class.

Local classes - Local classes are like local variables,
specific to a block of code. Their visibility is only within
the block of their declaration. In order for the class to be
useful beyond the declaration block, it would need to
implement a
more publicly available interface.Because local classes are
not members, the modifiers public, protected, private, and
static are not usable.

Anonymous classes - Anonymous inner classes extend local
inner classes one level further. As anonymous classes have
no name, you cannot provide a constructor.
 
Is This Answer Correct ?    1 Yes 0 No
Midhun H Kumar
 
  Re: what is inner class?
Answer
# 5
A class within another class is known as nested class. There
are two type of nested class static nested class and non
static nested class.The static nested class did'nt access
its enclosed member function directly, where an non static
nested class can directly access. the non static nested
class is known as inner class. There are 4 type of nestated
class they are  Nested top-level classes, Member classes,
Local classes, Anonymous classes....
 
Is This Answer Correct ?    1 Yes 0 No
Amit Kumar
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
byte a=5; byte b=5; byte c=a+b; System.out.println(c); whats the o/p? Wipro5
What is the middleware?  2
What is the diff. b/w Interfaces & Abstract class? Ericsson4
There are 2 methods in a class. Both have the same method signature except for return types. Is this overloading or overriding or what is it? KPIT7
what is difference between Action messages and Action errors? TCS1
what is j2se  3
What is finally in exception handling?  6
What are order of precedence and associativity, and how are they used?  1
Explain Public static void main?  2
What is JIT ? Satyam4
can abstract class have constructor how can you achive this ? Fidelity3
why there are multiple catches for a try block.don't tell me that there can be multiple exception of a code segment that's why.tell me the real fact behind this.  4
what is an object and how do you allocate memory to it? Wipro3
what are Checked & Unchecked exceptions ?  2
What are different type of access modifiers?  3
what is meant by serialization?  6
what is an anonymous class? TCS5
what is difference between prepare stetement and callable starement with example? CMC1
What is the return type of readLine() when end of a file is reached?  1
what is the difference between cd & dvd ? Satyam11
 
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