1). What is the range of short data type in Java?

[A]-128 to 127
[B] -32768 to 32767
[C]-2147483648 to 2147483647
[D]None of the mentioned

Show Answer

2). What is the range of byte data type in Java?

[A]-128 to 127
[B] -32768 to 32767
[C]-2147483648 to 2147483647
[D]None of the mentioned

Show Answer

3). Which of the following are legal lines of Java code?
 1. int w = (int)888.8;
   2. byte x = (byte)100L;
   3. long y = (byte)100;
   4. byte z = (byte)100L;

[A]1 and 2
[B]2 and 3
[C]3 and 4
[D]All statements are correct

Show Answer

4). An expression involving byte, int, and literal numbers is promoted to which of these?
 1. int w = (int)888.8;
   2. byte x = (byte)100L;
   3. long y = (byte)100;
   4. byte z = (byte)100L;

[A]int
[B]long
[C]byte
[D]float

Show Answer

5). Which of these literals can be contained in float data type variable?
 1. int w = (int)888.8;
   2. byte x = (byte)100L;
   3. long y = (byte)100;
   4. byte z = (byte)100L;

[A] -1.7e+308
[B] -3.4e+038
[C]+1.7e+308
[D]-3.4e+050

Show Answer

6). Which data type value is returned by all transcendental math functions?
 1. int w = (int)888.8;
   2. byte x = (byte)100L;
   3. long y = (byte)100;
   4. byte z = (byte)100L;

[A]int
[B]float
[C]double
[D]long

Show Answer

7). What will be the output of the following Java code?
   class average {
        public static void main(String args[])
        {
            double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
            double result;
            result = 0;
            for (int i = 0; i < 6; ++i) 
                result = result + num[i];
	    System.out.print(result/6);
 
        } 
    }

[A]16.34
[B]16.566666644
[C]16.46666666666667
[D]16.46666666666666

Show Answer

8). What will be the output of the following Java statement?
class output {
        public static void main(String args[]) 
        {
            double a, b,c;
            a = 3.0/0;
            b = 0/4.0;
            c=0/0.0;
 
	    System.out.println(a);
            System.out.println(b);
            System.out.println(c);
        } 
    }

[A]Infinity
[B]0.0
[C]NaN
[D]all of the mentioned

Show Answer

9). What will be the output of the following Java code?
    class increment {
        public static void main(String args[]) 
        {        
             int g = 3;
             System.out.print(++g * 8);
        } 
    }

[A]25
[B]24
[C]32
[D]33

Show Answer

10). What will be the output of the following Java code?
    class area {
        public static void main(String args[]) 
        {    
             double r, pi, a;
             r = 9.8;
             pi = 3.14;
             a = pi * r * r;
             System.out.println(a);
        } 
    }

[A]301.5656
[B]301
[C]301.56
[D]301.56560000

Show Answer