What are inner and anonymous class?

Answers were Sorted based on User's Feedback



What are inner and anonymous class?..

Answer / janet

Inner Class: classes defined in other classes ,including
those defined in methods are called inner classes.
An inner class can have any accessiblity including private.

Anonumous class: Anonymous class is a class defined inside
a method without a name and is instantiated and declared in
the same place and cannot have explicit constructors.

Is This Answer Correct ?    1 Yes 0 No

What are inner and anonymous class?..

Answer / sathya


Inner classes as name suggests, can be declared within a
class, as for that matter, with in a for statement too... or
with in a method of another class.

Anonymous classes are also inner classes but without a name,

The advantage being more abstraction of code, but more
confusing to beginners

Is This Answer Correct ?    0 Yes 0 No

What are inner and anonymous class?..

Answer / harika.thota001@gmail.com

Inner Class in java so called nested class is nothing but a class that is being defined inside another class. Inner classes are beneficial in two scenarios i.e. access control and naming control. Although these benefits can be acquired using java packages.

anonymous class is an inner class that does not have a name at all. And whose instance is being created at the time of its creation.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

How to find the largest value from the given array.

0 Answers  


What is meant by attribute?

0 Answers  


What is meant by inheritance and what are its advantages?

0 Answers  


my method "abc" return array of interface "xyz" and "pqr" is abstract class implements abc and class "jkl" extends pqr My problem 1) when i call abc it retrun array xyz how can i do this hint xyz refer_xyz = new jkl(); but i can't create array. 2)I want to access method of jkl using reference of xyz??

1 Answers  


which method is used to know the status of the Thread?

9 Answers   Honeywell,






What is boolean keyword in java?

0 Answers  


Can an exception be rethrown?

4 Answers   Wipro,


What is a Java package and how is it used?

2 Answers  


What is difference between == equals () and compareto () method?

0 Answers  


What is parameter example?

0 Answers  


I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor’s body?

0 Answers  


how to handle a singleton service locator. when multiple threads are trying to get the singleton object in same time

4 Answers   Mind Tree,


Categories