SCJP Module-7 Question-3


 

SCJP Module-7 Question-3

This program tests your understanding about the Number class and the int data type in Java.

This program tests your understanding about the Number class and the int data type in Java.

Given a sample code:

1    public class Test {
2    public static void main(String[] args) {
3    Number i=10;
4    int j = 10;
5    if (i.equals(j))
6    {
7    System.out.println("equals");
8    }
9    else
10  System.out.println("not equals");
}
}

What will be the result of above code ?

(1) not equal
(2) equal
(3) Compile time error at line no 3.
(4) Compile time error at line no 5.

Answer:

(2)

Ads