Thursday, April 1, 2010

Creating object of a class with private constructor outside the class

How to create object of a class with private constructor outside the class ? Pretty easy question !!! But below is hilarious concept revealed by a person who came for interview. I guess Sun, ohh Oracle should consider it as a feature for JDK 8.0

class RR {

private RR { }

}

//Outside class RR
this.rr { }


And object of class RR will be created.

3 comments:

  1. is this really Java Code????

    I need to study hard again...:(

    ReplyDelete
  2. One of such hilarious question that i came to know. If JAVA do not have pointers then why it has NullPointerException?...kya...hai koi javab....

    ReplyDelete
  3. You need to go back to college, study hard & refresh your skills. It is not good to be rejected by candidates being interviewed :)

    ReplyDelete