Java - MCQ

Multiple Choice Questions


Share with a Friend

 

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

36. What will be the output of the following Java code?

    class operators 
    {
        public static void main(String args[])
        {
            int var1 = 5; 
            int var2 = 6;
            int var3;
            var3 = ++ var2 * var1 / var2 + var2;
            System.out.print(var3);
        } 
    }
A). 56
B). 10
C). 12
D). 11
View Answer
Correct: C



37. What will be the output of the following Java code?

    class operators 
    {
        public static void main(String args[]) 
        {    
             int x = 8;
             System.out.println(++x * 3 + " " + x);
        } 
    }
A). 24 8
B). 24 9
C). 27 8
D). 27 9
View Answer
Correct: D



38. What will be the output of the following Java code?

class Output 
{
        public static void main(String args[]) 
        {    
             int x=y=z=20;
 
        } 
}
A). compile and runs fine
B). run time error
C). 20
D). compile time error
View Answer
Correct: D



39. What will be the output of the following Java program?

class Output 
{
        public static void main(String args[]) 
        {    
             int a,b,c,d;
             a=b=c=d=20
            a+=b-=c*=d/=20
           System.out.println(a+" "+b+" "+c+" "+d);
 
        } 
}
A). runtime error
B). compile time error
C). a=20 b=0 c=20 d=1
D). none of the mentioned
View Answer
Correct: C



40. Which of the following is not OOPS concept in Java?
A). Inheritance
B). Polymorphism
C). Encapsulation
D). Compilation
View Answer
Correct: D



 
 
 
   
   
   
UltraInfo Technologies
ITDeveloper