Integer and Floating Data Types

1

What is the output of this program?

    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

2

What is the output of this program?

    class increment {
        public static void main(String args[]) 
        {        
             int g = 3;
             System.out.print(++g * 8);
        } 
    }
A. 25
B. 24
C. 32
D. 33

3

What is the output of this program?

    class conversion {
        public static void main(String args[]) 
        {    
             double a = 295.04;
             int  b = 300;
             byte c = (byte) a;
             byte d = (byte) b;
             System.out.println(c + " "  + d);
        } 
    }
A. 38 43
B. 39 44
C. 295 300
D. 295.04 300

4

What is the output of this program?

    class asciicodes {
        public static void main(String args[]) 
        {
            char var1 = 'A';
	    char var2 = 'a';
	    System.out.println((int)var1 + " " + (int)var2);
        } 
    }
A. 162
B. 65 97
C. 67 95
D. 66 98

5

What is the output of this program?

 
    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