D1]
class ch_zero{
public static void main(
String args[]){
if(0.0 >- 0.0){System.out.println("0.0 is greater");}
else
if(-0.0>0.0){System.out.println("-0.0 is greater");} //FIRST CHECK FOR 0.0
else
System.out.println("0.0 and -0.0 are equal");
System.out.println(0.0 ==-0.0);//SECOND CHECK FOR 0.0
if(0 >- 0){System.out.println("0 is greater");}
else
if(-0 >0){ System.out.println("-0is greater");} //FIRST CHECK FOR 0
else
System.out.println("-0 and 0 are equal");
System.out.println(0 ==-0);//SECOND CHECK FOR 0
System.out.println(Math.min(0.0,-0.0));
System.out.println(Math.max(0.0,-0.0));
System.out.println(Math.min(0,-0));
System.out.println(Math.max(0,-0));
}
}
in the above code both the cheks for 0.0 prove that 0.0 equals -0.0
then why does min() and max() methods give diff answers.
D2]
Assume that th is an instance holding a
thread object. th.start() causes the thread to start running and eventually complete its execution. The object reference by th is not accessable any more and is garbage collected when the garbage collecter runs.
True
False
ans = false why?
D3]
The following code builds a GUI with a single button.
1. import java.awt.*;
2.
3. public class Q6 extends Frame {
4. setSize(500,500);
5. setLayout(new FlowLayout( ) );
6.
7.
8. Button b = new Button("Where am I ?");
9. Panel p1 = new Panel( );
10. p1.setLayout(new FlowLayout(FlowLayout.LEFT ));
11. Panel p2 = new Panel( );
12. p2.setLayout(new BorderLayout( ));
13. panel p3 = new Panel( );
14. p3.setLayout(new GridLayout( 3, 2 ) );
15.
16. p1.add(b);
17. p2.add(p1, BorderLayout.NORTH);
18. p3.add(p2);
19. add(p3);
20 }
21.
22. public static void main(String args[ ]) {
23. Q6 that = new Q6( );
24. that.setVisible(true);
25. }
26. }
i can't figure out the ans .can somebody help?
D4]
class ch_inner1{
ch_inner1(){
new inner().meth1(); // line 2
}
public static void main(String args[]){
//new ch_inner1().new inner().meth1(); // -----line 1
new ch_inner1();
}
class inner{
void meth1(){
System.out.println("inner");
}
}
}
in the ex D4]
if at line1 i try to instantiate inner class as follows and call the method meth1
new inner().meth1();
i get compile time error saying instane of outer class req.
from which i conclude that inner class can not be craeted without the instance of it's outer class.
but then again if i call method meth1() as in line two without instaniating outer class this time from the constructor of outer class i do not get any errors.
what's happening here.
pleas clarify my doubt.