Is it possible to write method inside method

Answers were Sorted based on User's Feedback



Is it possible to write method inside method..

Answer / divya

no,it's not possible to write method inside a method.it
will gives an error illigal starts of expression

Is This Answer Correct ?    18 Yes 4 No

Is it possible to write method inside method..

Answer / janeesh

it is possible to write a method inside a method by using
method local inner classes.
Eg:
class Outer {


public void display() {
System.out.println("This is outerclass method.");

class Inner{

public void displayInner()
{
System.out.println("innerclass method");
}

}
Inner objC = new Inner();
objC.displayInner();
}
}
class MethodeInsideMethod {
public static void main(String[] args) {
Outer objC = new Outer();
objC.display();
}

}


Output:
This is outerclass method.
innerclass method

Is This Answer Correct ?    11 Yes 5 No

Is it possible to write method inside method..

Answer / mitul

Answer #2 is correct

Is This Answer Correct ?    7 Yes 1 No

Is it possible to write method inside method..

Answer / umesh

Answer #2 is wrong

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More Core Java Interview Questions

How do you create a first line indent?

0 Answers  


What purpose do the keywords final, finally, and finalize fulfill?

0 Answers  


How much is a java license?

0 Answers  


How many types of constructors are used in java?

0 Answers  


Tell me are there implementations for sorting and searching in the java libarary?

0 Answers  






Why does java have different data types for integers and floating-point values?

0 Answers  


What class allows you to read objects directly from a stream?

0 Answers  


Define reflection.

0 Answers  


What should I import for arraylist in java?

0 Answers  


What is the difference between stringbuffer and stringbuilder class?

0 Answers  


What about member inner classes?

0 Answers  


What is numeric function?

0 Answers  


Categories