Fun with Java

  • warning: include(/tmp/fortune.txt): failed to open stream: No such file or directory in /home/mohawksoft/org/www/htdocs/includes/common.inc(1696) : eval()'d code on line 1.
  • warning: include(): Failed opening '/tmp/fortune.txt' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/mohawksoft/org/www/htdocs/includes/common.inc(1696) : eval()'d code on line 1.

This is my favorite question to ask on an interview:

Given this java program, what is the output and why?

public class test
{
	public static void main (String args[])
 	{
		Integer a = 5;
		Integer b = 5;
		Integer c = 2000;
		Integer d = 2000;
		if(a == b)
			System.out.println("a==b");
		else
			System.out.println("a!=b");
		if(c==d)
			System.out.println("c==d");
		else
			System.out.println("c!=d");
	}
}

The Answer