Ques 1) It is written in JLS that NaN is unordered. So comparing it with another NaN always results in False.
However look at this code:
class t {
public static void main(
String args[]){
Double a = new Double(Double.NaN);
Double b = new Double(Double.NaN);
System.out.println(b.equals(b));
}
}
It produces output TRUE. How is this possible . We know that equals compare the contents of Objects meaning here it should check for the Values of a & b, but as they are unordered therefore it should return false.
-------------------------------------------------------------------------------------
import java.applet.*;
2: import java.awt.*;
3:
4: public class Q20 extends
Applet 5: {
6: Button okButton = new Button("Ok");
7:
8: public void init()
9: {
10: setLayout(new BorderLayout());
11:
12: add("South", okButton);
13: add("North", okButton);
14: add("East", okButton);
15: add("West", okButton);
16: add("Center", okButon);
17:
18: setSize(300,300);
19: }
20: }
A) Five Buttons with label "Ok" at Top, Bottom, Right, Left and Center of the Applet.
B) Only one Button with label "Ok" at the Top of the Applet.
C) Only one Button with label "Ok" at the Bottom of the applet.
D) Only one Button with label "Ok" at the Center of the Applet.
Ans is D but How
----------------------------------------------------------------------------------------------
Ques 3). import java.applet.*;
import java.awt.*;
public class t extends Applet
{
Button okButton = new Button("Ok");
public void init()
{
setLayout(new GridLayout(2,2));
add( okButton);
add(okButton);
add( okButton);
add( new Button("4"));
add( new Button("5"));
setSize(300,300);}
}
This shows only 3 buttons with captions OK,4,5.Can anyone tell what basically happens when we add a single object reference to a Component as here we have added the same object reference okButton 3 times.What is the concept behind this.
HELP ???/