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 ?    17 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 can we find the sum of two linked lists using stack in java?

0 Answers  


What is native code?

0 Answers  


Can interface be private in java?

0 Answers  


what is session facade ?

3 Answers  


Explain importance of throws keyword in java?

0 Answers  






Is vector ordered in java?

0 Answers  


How do you sing an Applet ?

0 Answers  


Write the program numbers into words.For example 2345==two thousand three hundred fourty five

2 Answers   TCS,


I declared main() method as private. But it still running and displaying the output. Please Answer it . Code Snippet as Below: import java.io.*; class over { private static void main(String[] args) { int high = Integer.MAX_VALUE; int overflow = high + 1; int low = Integer.MIN_VALUE; int underflow = low - 1; System.out.println(high + "\n" +overflow +"\n"+ low +"\n"+underflow); //System.out.println(overflow); //System.out.println(low); //System.out.println(underflow); } }

4 Answers   Cap Gemini,


Is space a char?

0 Answers  


Is null keyword in java?

0 Answers  


What does replaceall do in java?

0 Answers  


Categories