<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hashbrown on the Mic &#187; puzzler</title>
	<atom:link href="http://hashbrownonthemic.com/tag/puzzler/feed/" rel="self" type="application/rss+xml" />
	<link>http://hashbrownonthemic.com</link>
	<description>Riffs from an overheated mind</description>
	<lastBuildDate>Sun, 23 Aug 2009 17:56:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Java Interview Puzzler</title>
		<link>http://hashbrownonthemic.com/2009/06/18/java-interview-puzzler/</link>
		<comments>http://hashbrownonthemic.com/2009/06/18/java-interview-puzzler/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 23:34:30 +0000</pubDate>
		<dc:creator>hashbrown</dc:creator>
				<category><![CDATA[geek stuff]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[puzzler]]></category>

		<guid isPermaLink="false">http://hashbrownonthemic.com/?p=202</guid>
		<description><![CDATA[This is a puzzler we created at my work to use as an interview problem.  I had a fun time taking it myself, and got it wrong the first time!  It was designed to mimic some bad legacy code you might encounter when working on a large aging system, that has passed through [...]]]></description>
			<content:encoded><![CDATA[<p>This is a puzzler we created at my work to use as an interview problem.  I had a fun time taking it myself, and got it wrong the first time!  It was designed to mimic some bad legacy code you might encounter when working on a large aging system, that has passed through many hands.  Terrible coding practices, no javadocs or comments, etc.  You are tasked to figure out what the heck it does.<br />
First &#8211; does it compile?  If not, how do you fix it?<br />
Second &#8211; If it compiles, what is the output?</p>
<p>I&#8217;ll answer questions and post the solution in the comments.</p>
<pre class="brush: java;">
package crazy;

public class Timing extends R {
    public static final Integer t = new Integer(&quot;4&quot;);

    public static void main(String[] args) {
        Timing t = new Timing(11);

        System.out.print(t.foo);
        bat(t);
    }

    void fob() { fod(); }

    public Timing(int value) {

        super();
        foo = foo % value;
        bar();
    }

    static {
        System.out.print(&quot;6&quot;);

    }

    private void bar() {
        new Baz().bar(5);
        tr = &quot;2&quot;;
    }

    private int foo = 25;

    static void r() { System.out.println(&quot;1&quot;); }
}

abstract class R {

    String tr = &quot;9&quot;;

    static void bat(R r) {
        r.fob();
        System.out.print(r.tr);

    }

    private int negate(int bam) {
        return bam * -1;
    }

    public R() {
        System.out.print(&quot;7&quot;);
    }

    void fod() { System.out.print((int)Math.floor(.99)); }

    protected final int t() {
        return 5;
    }

    class Baz {

        void bar(int fob) {
            if (fob == 9)
                System.out.print(String.valueOf(fob++));

                System.out.print(String.valueOf(negate(fob++)));
            if (fob == 5)
                System.out.print(String.valueOf(fob+=2));

        }
    }

    static {
        System.out.print(&quot;8&quot;);
    }

    abstract void fob();

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://hashbrownonthemic.com/2009/06/18/java-interview-puzzler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
