Guess the output of the following program

Try to guess without running the program.
Code
  1. public class IntegerClassExampleThree {

  2.  public static void main(String[] javalatte) {

  3.   Integer i = 400;

  4.   Integer j = 400;

  5.   if(i==j){

  6.    System.out.println("i==j is equal");

  7.   }else {

  8.    System.out.println("i==j is not equal");

  9.   }

  10.  }

  11.  

  12. }

  13. public class IntegerClassExampleFour {

  14.  public static void main(String[] javalatte) {

  15.   Integer i = 127;

  16.   Integer j = 127;

  17.   if(i==j){

  18.    System.out.println("i==j is equal");

  19.   }else {

  20.    System.out.println("i==j is not equal");

  21.   }

  22.  }

  23.  

  24. }
Copyright GeekInterview.com

Questions by pardeep131085   answers by pardeep131085

Showing Answers 1 - 9 of 9 Answers

prashanth

  • Dec 2nd, 2013
 

i==j is not equal

  Was this answer useful?  Yes

onkar

  • Dec 28th, 2013
 

1. First of all in one java file you can not have two public classes.

2. Second you will have to run a particular public class "java classname" and then its main method would run.

Note - If there is no main, you would create object of that class or make it static to access its methods. Another thing is what we call as reflection. One more is overriding where JVM will call that method.

  Was this answer useful?  Yes

mani

  • May 28th, 2014
 

int value ends at 127 so upto 127 the hash code for int value is same.the answer is not equal and equal

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions