ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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
تم إضافة السؤال من قبل Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
تاريخ النشر: 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.

 

Mukesh Verma
من قبل Mukesh Verma

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.

 

المزيد من الأسئلة المماثلة