Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

Can we convert integer to string in java?

0 Answers  


what do you mean by java annotations?

0 Answers  


How many types of voids are there?

0 Answers  


What is null data type?

0 Answers  


When should I use singleton pattern?

0 Answers  






write a program that list all permutations of ABCDEF in which A appears before B?

0 Answers   Nissan,


Explain about object oriented programming and its features?

0 Answers  


What is lifetime variable?

0 Answers  


Can we overload final method in java?

0 Answers  


Can a list be null in java?

0 Answers  


Can we extend a class with private constructor?

0 Answers  


What happens when a thread cannot acquire a lock on an object in java programming?

0 Answers  






Categories