Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

JAVA QUESTIONS

What is Anonymous Inner Classes?
As the name suggests ,  word anonymous means not identified with name. So, there is no name of the anonymous inner classes , and their type must be either a subclass of the named type or an implementer of the named interface.
Example of Anonymous class below  :
class Apple {
    public void iphone() {
        System.out.println("iphone");
    }
}
class Mobile {
    Apple apple = new Apple() {
        public void iphone() {
            System.out.println("anonymous iphone");
        }
    };
An anonymous inner class is always treated like a statement in the class code , and remember to close the statement after the class definition with a curly brace. It is rare to found the curly braced followed by semi colon in java .
When Finally Block is NOT called?
Finally is the block of code that executes always. The code in finally block will execute even if an exception is occurred. Finally block is NOT called in following conditions
If the JVM exits while the try or catch code is being executed, then the finally block may not execute. This may happen due to System.exit() call.
if the thread executing the try or catch code is interrupted or killed, the finally block may not execute even though the application as a whole continues.
If a exception is thrown in finally block and not handled then remaining code in finally block may not be executed.

 Visit:www.sssedu.inhttp://sssedu.in/java-training-in-chennai.html


This post first appeared on Sakthi Software Solutions, please read the originial post: here

Share the post

JAVA QUESTIONS

×

Subscribe to Sakthi Software Solutions

Get updates delivered right to your inbox!

Thank you for your subscription

×