Re: Interesting Java interview question
Dan Leifker wrote:
A friend of mine likes to ask this question when interviewing Java
developers. Thought I'd pass it along because it's sort of interesting.
Why does the following compile, and what does the output look like?
System.out.println(new Object(){{{}}}.toString());
He says he has asked this question of several dozen people, and almost
everyone just stares at it in shock. Only one has answered it
correctly. I wish I had his resume...
Well, that one was pretty simple, and Eclipse already stated that I
should document my empty code block :)
Of course, I make more frequent use of
System.out.println(new Object(){static{{}}}.toString());
since most initialization can be done within a constructor.
Maarten
.
Relevant Pages
- Re: ADA Popularity Discussion Request
... but you don't get this sort of extremely interactive incremental ... > compile time and the program at run time, ... The "both" here is typically not true in static languages. ... In a dynamic language, _values_ have types, variables are just binding ... (comp.lang.ada) - Re: D3/Linux program abort
... same sort of fire could occur anywhere. ... Most developers are ... error message so that we can get through diagnostics quickly and get ... There's also the "techno error" that developers tend to display when ... (comp.databases.pick) - Re: additional requirements for a Ruby env
... decent compiler toolchain to compile itself) then developers would be freed to ... compile them up themselves. ... cross platform image magic installation when the build process of ruby itself ... suffering increases your inner strength. ... (comp.lang.ruby) - CL subset?
... language in a conscious effort to create smaller distributables. ... case of COMPILE and friends, they wouldn't be giving up much at all. ... it seems the most obvious way to implement this sort of thing is to ... LISP" question. ... (comp.lang.lisp) - Re: Programmers unpaid overtime.
... > I need to avoid a practical problem which other developers ignore. ... practical example (which will compile) and your alternative that is ... you apply them after NOT using precise terminology and getting ... > then waste thousands of man-hours when applied to real data sets. ... (comp.programming) |
|