Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Can we define a method inside a method in java ? What is AnonymousClass in java ? can we define a Anonymous class inside interface ?

user-image
Question ajoutée par Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
Date de publication: 2013/12/26

no, java not support method inside m ethod. we get compile time exception saying illigal start of expression.

anonymus class is a class that class does n't containt any name. we use it  only for one time .

eg:  new Thread(){

public void run(){

System.out.println("anonymus example prog");

}}.start();

no.we conn't define anonymus class inside inter face. becoz anonymus inner class contain some implemention and doesn't contain any name. we can define inner class.

we can define anonymus inner class inside class.

 

No, Java does not support "directly" nested methods. (Most functional languages do though, including some JVM languages such as Scala and Clojure!).

 Anonymous class define inside of a method,that have no name is called anonymous Class.

No  ,we cannot define Anonymous Class inside Interface . but we can define Inner Class.

 

More Questions Like This