Tuesday, June 28, 2011

Don’t expect the Exceptions


Do you think you can expect the Exceptions? Yes YOU CAN





public class Null {
   
    static String value = "Are you expecting Null Pointer????";

    Null getNull() {

        return null; // attention attention !!!!!  
    }

    public static void main(final String args[]) {

        final Null Null = new Null();

        System.out.println(Null.getNull().value);
    }
}

Who can tell me the output of this program without executing????

Tricky One!!!!!!!!!

3 comments:

Mice said...

Hehe :)

Sparzrc1 - ebuka@exacron.com said...

I don't think it would run because the modifier for the method getNull() is not valid. And there are many more errors.

Kumar said...

Hi Ebuka,
It’s in default modifier. Calling method (default modifier) with in a class is Legal. Nothing wrong in that. i can assure you that no compilation error. Now guess the output
Ps : u haven’t reached the heart of this program 

Post a Comment

Related Posts Plugin for WordPress, Blogger...