C Programming Multiple Choice Questions (MCQ) | IT Developer <?php echo $page_title; ?>
IT Developer

Java Programming Multiple Choice Questions (MCQ)

Introduction to Java - Multiple Choice Questions (MCQ) - Set 20



Share with a Friend

Multiple Choice Questions


Java - Introduction to Java - Multiple Choice Questions (MCQ) - Set 20

96. What will be the output of the following Java code?
    class Relational_operator 
    {
        public static void main(String args[])
        {
            int var1 = 5; 
            int var2 = 6;
            System.out.print(var1 > var2);
        } 
    }
A). 1
B). 0
C). True
D). False
View Answer
Correct: D




97. What will be the output of the following Java code?
    class bool_operator 
    {
        public static void main(String args[]) 
        {    
             boolean a = true;
             boolean b = !true;
             boolean c = a | b;
             boolean d = a & b;
             boolean e = d ? b : c;
             System.out.println(d + " " + e);
        } 
    }
A). false false
B). true true
C). true false
D). false true
View Answer
Correct: D




98. What will be the output of the following Java code?
    class ternary_operator 
    {
        public static void main(String args[]) 
        {        
             int x = 3;
             int y = ~ x;
             int z;
             z = x > y ? x : y;
             System.out.print(z);
        } 
    }
A). 0
B). 1
C). 3
D). -4
View Answer
Correct: C




99. What will be the output of the following Java code?
    class Output 
    {
        public static void main(String args[]) 
        {    
             int x , y = 1;
             x = 10;
             if (x != 10 && x / 0 == 0)
                 System.out.println(y);
             else
                 System.out.println(++y);
        } 
    }
A). 1
B). 2
C). Runtime error owing to division by zero in if condition
D). Unpredictable behavior of program
View Answer
Correct: B




100. What will be the output of the following Java code?
    class Output 
    {
        public static void main(String args[]) 
        {    
             boolean a = true;
             boolean b = false;
             boolean c = a ^ b;
             System.out.println(!c);
        } 
    }
A). 0
B). 1
C). false
D). true
View Answer
Correct: C