Type Conversions, Promotions and Castings

1

What is the output of this program?

    class c {    
        public void main( String[] args ) 
        {  
            System.out.println( "Hello" + args[0] ); 
        } 
    }
A. Hello c
B. Hello
C. Hello world
D. Runtime Error.

2

What is the output of this program?

    class A {
        final public int calculate(int a, int b) { return 1; } 
    } 
    class B extends A { 
        public int calculate(int a, int b) { return 2; } 
    } 
     public class output {
        public static void main(String args[]) 
        { 
            B object = new B(); 
            System.out.print("b is " + b.calculate(0, 1));  
        } 
    }
A. b is : 2
B. b is : 1
C. Compilation Error.
D. An exception is thrown at runtime.

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 char_increment {
        public static void main(String args[]) 
        {
            char c1 = 'D';
            char c2 = 84;
            c2++;
            c1++;
            System.out.println(c1 + " "  + c2);
        } 
    }
A. E U
B. U E
C. V E
D. U F

5

What is Truncation is Java?

A. Floating-point value assigned to an integer type.
B. Integer value assigned to floating type.
C. Floating-point value assigned to an Floating type.
D. Integer value assigned to floating type.