Is it possible to write method inside method
Answers were Sorted based on User's Feedback
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 |
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 |
What is static variable with example?
what is difference between abstraction and interface?
If a multi threaded Java program has started numerous number of threads, at any point in time how to know which thread is currently executing/running ?
7 Answers Accenture, College School Exams Tests, iFlex, NIIT,
What is difference between compatible and incompatible changes in serialization?
whst is encapsulation?when u encpsulate actually while devoloping code?
What is a class variable?
what happens when a thread cannot acquire a lock on an object? : Java thread
what is struts-config-xml?and its use?
What is backdrop?
For ease of programming you can consider the maze as a 2D array with colors represented by below integer and characters (in capital letters). • B - Black • W -White • G- Green • R- Red R B W B W W W W W W B W B B W W W W W W W B W B W W W B W W W W B B W W W B W W W B W W B B B B W B W B W W B W W W B W W W B B B W W B W W W B W W B W B W W W B W B W W W W B B W W W W B W W W W W G Shortest Route Problem: • Solution that finds the shortest Route between Red and Green  White will have 1 Weight.  Red and Green carry no weights.  Shortest path is the path with less weight when you add up the weights in the path.
Compare Mutex and Semaphore in java.
How can you make sure that your singleton class will always return single instance in multi-threaded environment?