Quiz Discussion

What will be the output of the following Java program?

    class rightshift_operator 
    {
        public static void main(String args[]) 
        {    
             int x; 
             x = 10;
             x = x >> 1;
             System.out.println(x);
        } 
    }

 

Course Name: Java

  • 1]

    10

  • 2]

    5

  • 3]

    2

  • 4]

    20

Solution
No Solution Present Yet

Top 5 Similar Quiz - Based On AI&ML

Quiz Recommendation System API Link - https://fresherbell-quiz-api.herokuapp.com/fresherbell_quiz_api

# Quiz
1
Discuss

Which of these statements are incorrect?

  • 1]

    Equal to operator has least precedence

  • 2]

    Brackets () have highest precedence

  • 3]

    Division operator, /, has higher precedence than multiplication operato

  • 4]

    Addition operator, +, and subtraction operator have equal precedence

Solution
2
Discuss

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);
        } 
    }

 

  • 1]

    1

  • 2]

    2

  • 3]

    Runtime error owing to division by zero in if condition

  • 4]

    Unpredictable behavior of program

Solution
3
Discuss

Which of these lines of Java code will give better performance?

   1. a | 4 + c >> b & 7; 
   2. (a | ((( 4 * c ) >> b ) & 7 ))
  • 1]

    1 will give better performance as it has no parentheses

  • 2]

    2 will give better performance as it has parentheses

  • 3]

    Both 1 & 2 will give equal performance

  • 4]

    Dependent on the computer system

Solution
4
Discuss

Which of these is not a bitwise operator?

  • 1]

    &

  • 2]

    &=

  • 3]

    |=

  • 4]

    <=

Solution
5
Discuss

What will be the output of the following Java program?

    class increment 
    {
        public static void main(String args[])
        {
            double var1 = 1 + 5; 
            double var2 = var1 / 4;
            int var3 = 1 + 5;
            int var4 = var3 / 4;
            System.out.print(var2 + " " + var4);
 
        } 
    }

 

  • 1]

    1 1

  • 2]

    0 1

  • 3]

    1.5 1

  • 4]

    1.5 1.0

Solution
6
Discuss

Which of the following operators can operate on a boolean variable?

   1. &&
   2. ==
   3. ?:
   4. +=
  • 1]

    3 & 2

  • 2]

     1 & 4

  • 3]

     1, 2 & 4

  • 4]

    1, 2 & 3

Solution
7
Discuss

Which of these operators can skip evaluating right hand operand?

  • 1]

    !

  • 2]

    |

  • 3]

    &

  • 4]

    &&

Solution
8
Discuss

What will be the output of the following Java program?

    class Modulus 
    {
        public static void main(String args[]) 
        {    
             double a = 25.64;
             int  b = 25;
             a = a % 10;
             b = b % 10;
             System.out.println(a + " "  + b);
        } 
    }

 

  • 1]

    5.640000000000001 5

  • 2]

    5.640000000000001 5.0

  • 3]

    5 5

  • 4]

    5 5.640000000000001

Solution
9
Discuss

Decrement operator, −−, decreases the value of variable by what number?

  • 1]

    1

  • 2]

    2

  • 3]

    3

  • 4]

    4

Solution
10
Discuss

Which of these have highest precedence?

  • 1]

    ()

  • 2]

    ++

  • 3]

    *

  • 4]

    >>

Solution
# Quiz