here are the two questions which i am not able to get. they are from the mock exams taken from certification4career.com.
Double a=new Double(Double.NAN)
Double b= new Double(Double.NAN);
if (a.equals(b))
System.out.println("true);
System.out.println("false");
here the out put is true.
wht abt this question
class MyClass
{
int maxElements;
MyClass(int maxElements)
{
this.maxElements = maxElements;
}
}
public class Q19
{
public static void main(
String[] args)
{
MyClass a = new MyClass(100);
MyClass b = new MyClass(100);
if(a.equals(b))
System.out.println("Objects have the same values");
else
System.out.println("Objects have different values");
}
}
the output is objects have different values.
why is this so. whether i declare it as static or not the ouput is same. why is this?