What is an anonymous class?



What is an anonymous class?..

Answer / sai

An anonymous class is a local class without a name. An
anonymous class is defined and instantiated in a single
succinct expression using the new operator.

Example:
class popcorn{
public void eat(){
syso("popcorn is sweet");
}
public void m1(){
syso("popcorm method");
}
class sample{
public static void main(String args[]){
popcorn p = new popcorn(){
public void eat(){
syso("popcorn is so hot");
}
};
p.eat();
p.m1();
}
}

Is This Answer Correct ?    17 Yes 3 No

Post New Answer

More Core Java Interview Questions

define System.out.println(); what is the meaning!

19 Answers   Accenture,


What are the skills required for core java?

0 Answers  


What is the use of ?this??

4 Answers  


What is a singleton puppy?

0 Answers  


What is user defined exception?

4 Answers  






How many types of assembly languages are there?

0 Answers  


What is style and indentation?

0 Answers  


For ease of programming you can consider the maze as a 2D array with colors represented by below integer and characters (in capital letters). • B - Black • W -White • G- Green • R- Red R B W B W W W W W W B W B B W W W W W W W B W B W W W B W W W W B B W W W B W W W B W W B B B B W B W B W W B W W W B W W W B B B W W B W W W B W W B W B W W W B W B W W W W B B W W W W B W W W W W G Shortest Route Problem: • Solution that finds the shortest Route between Red and Green  White will have 1 Weight.  Red and Green carry no weights.  Shortest path is the path with less weight when you add up the weights in the path.

0 Answers  


Definition for connection pooling?

3 Answers  


What is immutable in java?

0 Answers  


what are literals in java?

2 Answers  


whats is the use of final,in which situation final can be used in the application?

2 Answers   DNS,


Categories