Answer Posted / 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 |
Post New Answer View All Answers
Can finally block be used without a catch?
Explain polymorphism citing an example.
Is string is a data type?
can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread
What is a Transient Object?
Does treeset allow null in java?
Explain java coding standards for constants?
What is static keyword?
What are the steps that are followed when two computers connect through tcp?
What is a flag variable?
What are different types of inner classes ?
Why heap memory is called heap?
Why java is platform independent? Explain.
Can we use synchronized block for primitives?
when to use ArrayList and when to use HashMap in webApplication.