|
No. |
Java Question |
Answer/Output |
Explanation |
|
1 |
SOP(~Integer.MAX_VALUE
== Integer.MIN_VALUE); |
True |
- |
|
2 |
SOP(Math.min(-0f,0f)); |
-0.0 |
- |
|
3 |
SOP(Math.min(-0f, 0f)= =0f); |
True |
- |
|
4 |
SOP(Math.round(Long.MAX_VALUE + 1.5)
= = Long. MAX_VALUE); |
True |
- |
|
5 |
SOP(Math.round(Integer.MIN_VALUE - 6.5f)
= = Integer.MIN_VALUE); |
True |
- |
|
6 |
Math.round (Integer.MIN_VALUE -6.5)
= = Integer.MIN_VALUE); |
False |
- |
|
7 |
SOP(Math.min(-0.0,+0.0)); |
-0.0 |
- |
|
8 |
SOP(Math.max (-0.0, +0.0)); |
+0.0 |
|
|
9 |
SOP( Math.min(-0.0, +0.0)
= = Math.max (0.0, +0.0))); |
True |
The oder of floating or the double values is Infinity->Negative Numbers/Fractions->-0.0->+0.0->positive
numbers/Fractions->Infinity |
|
10 |
double d = -0.5;
SOP(Math.Ceil (d)); |
-0.0 |
- |
|
11 |
SOP(-1 * Double.NEGATIVE
_INFINITY); |
Infinity |
- |
|
12 |
SOP(1 * Double.NEGATIVE
_INFINITY); |
-Infinity |
- |
|
13 |
SOP(int a = Integer.MAX_VALUE + 1); |
-2147483648 |
- |
|
14 |
SOP(int a = Integer.MIN_VALUE - 1); |
2147483648 |
- |
|
15 |
SOP(Math.abs(Integer.MIN_VALUE)); |
-2147483648 |
This is the Integer.MIN
_VALUE |
|
16 |
SOP(Math.min(0.0,-0.0); |
-0.0 |
- |
|
17 |
SOP(Math.round(Float.MAX_VALUE)); |
Integer.MAX_VALUE |
- |
|
18 |
Integer i = new Integer("10");
i.toString() = = i.toString(); |
True |
Only upto 0 to 10 remaining all results false for both Integers, Bytes. The toString()
method returns String equivalent of this String object. It creates a new object
each time it is called. The = = operator compares the bit patterns of the two object
references and not the actual String contents. |
|
19 |
SOP(Math.abs(Float.MIN_
VALUE) > 0); |
True |
- |
|
20 |
SOP(Math.abs(Double.MIN
_VALUE) > 0); |
True |
- |
|
21 |
SOP(Math.abs(Integeer.MIN_
VALUE) > 0); |
False |
- |
|
22 |
SOP(Math.abs(Long.MIN_
VALUE) > 0); |
False |
- |
|
23 |
Integer i = new Integer(21);
Integer j = new Integer(10);
SOP(i+j); |
Compile
Time Error |
+ cannot be applied to Integer |
|
24 |
Integer i = new Integer(21);
Integer j = new Integer(10);
SOP((i+j).toString()); |
Compile
Time Error |
- |
|
25 |
Integer i = new Integer(21);
Integer j = new Integer(10);
SOP(""+i+j); |
2310 |
- |
|
26 |
Integer i = new Integer(21);
Integer j = new Integer(10);
SOP(i+""+j); |
2310 |
- |
|
27 |
Integer i = new Integer(21);
Integer j = new Integer(10);
SOP(i.toString()+j.toString()); |
2310 |
- |
|
28 |
SOP(Math.min(Float.NaN, Float.POSITIVE_INFINITY)); |
NaN |
- |
|
29 |
SOP(Math.min(Float.NaN,0.0); |
NaN |
- |
|
30 |
SOP(Math.max(Float.NaN, Float.POSITIVE_INFINITY)); |
NaN |
- |
|
31 |
SOP(Math.min(Float.NaN,Float.NEGATIVE_
INFINITY)); |
NaN |
- |
|
32 |
SOP(Math.max(Float.NaN,0.0)); |
NaN |
- |
|
33 |
SOP(Math.max(Float.NaN,Float.NEGATIVE_
INFINITY)); |
NaN |
- |
|
34 |
SOP(Math.max(Float.POSITIVE_INFINITY,
Double.POSITIVE_INFINITY)); |
Infinity |
- |
|
35 |
SOP(Float.POSITIVE_INFINITY = = Double.POSITIVE_INFINITY); |
True |
- |
|
36 |
SOP(Float.NEGATIVE_INFINITY= = Double.NEGATIVE_INFINITY) |
True |
- |