Multiple choice

class sample6 { public static void main(String []args) { Double i = 10.0; Double j = 11.0; Double k = ++i; //INCRSystem.out.println("k == j is" + (k == j)); System.out.println("k.equals(j) is" + k.equals(j)); } } Which of the following options correctly describes the behavior of this program?

  1. When executed, this program printsk == j is falsek.equals(j) is false

  2. When executed, this program printsk == j is truek.equals(j) is false

  3. When executed, this program printsk == j is falsek.equals(j) is true

  4. When executed, this program printsk == j is truek.equals(j) is true

  5. When compiled, the program will result in a compiler error in the line marked with the comment INCR.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Equals () function return true when they have same memory location assigned to it.