Object Oriented Programming - I (3140705) MCQs

MCQs of Introduction to java and elementary programming

Showing 31 to 40 out of 95 Questions
31.
Which of these have highest precedence?
(a) ()
(b) ++
(c) *
(d) >>
Answer:

Option (a)

32.
What should be expression1 evaluate to in using ternary operator as in this line?
 expression1 ?  expression2  :  expression3
(a) Integer
(b) Floating – point numbers
(c) Boolean
(d) None of the mentioned
Answer:

Option (c)

33.
What is the value stored in x in the following lines of Java code?
   int x, y, z;
    x = 0;
    y = 1;
    x = y = z = 8;
(a) 0
(b) 1
(c) 9
(d) 8
Answer:

Option (d)

34.
What is the order of precedence (highest to lowest) of following operators?
    1. &    
    2. ^
    3. ?:
(a) 1 -> 2 -> 3
(b) 2 -> 1 -> 3
(c) 3 -> 2 -> 1
(d) 2 -> 3 -> 1
Answer:

Option (a)

35.
Which of these statements are incorrect?
(a) Equal to operator has least precedence
(b) Brackets () have highest precedence
(c) Division operator has higher precedence than multiplication operator
(d) Addition operator and subtraction operator have equal precedence
Answer:

Option (c)

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) 10
(b) 11
(c) 12
(d) 56
Answer:

Option (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
Answer:

Option (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) 20
(c) run time error
(d) compile time error
Answer:

Option (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) compile time error
(b) runtime error
(c) a=20 b=0 c=20 d=1
(d) none of the mentioned
Answer:

Option (c)

40.
Which of the following is not OOPS concept in Java?
(a) Inheritance
(b) Encapsulation
(c) Polymorphism
(d) Compilation
Answer:

Option (d)

Showing 31 to 40 out of 95 Questions