Quiz Discussion

 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;
Course Name: Java

  • 1]

    0

  • 2]

    1

  • 3]

    9

  • 4]

    8

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

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

 

  • 1]

    1

  • 2]

    0

  • 3]

    true

  • 4]

    false

Solution
2
Discuss

Which of these is returned by “greater than”, “less than” and “equal to” operators?

  • 1]

    Integers

  • 2]

    Floating – point numbers

  • 3]

    Boolean

  • 4]

    None of the mentioned

Solution
3
Discuss

What should be expression1 evaluate to in using ternary operator as in this line?

 expression1 ?  expression2  :  expression3
  • 1]

    Integer

  • 2]

    Floating – point numbers

  • 3]

    Boolean

  • 4]

    None of the mentioned

Solution
4
Discuss

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

 

  • 1]

    0

  • 2]

    1

  • 3]

    3

  • 4]

    -4

Solution
5
Discuss

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

 

  • 1]

    10

  • 2]

    5

  • 3]

    2

  • 4]

    20

Solution
6
Discuss

Which of these have highest precedence?

  • 1]

    ()

  • 2]

    ++

  • 3]

    *

  • 4]

    >>

Solution
7
Discuss

With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?

   1. x++;
   2. x = x + 1;
   3. x += 1;
   4. x =+ 1;
  • 1]

    1, 2 & 3

  • 2]

    1 & 4

  • 3]

    1, 2, 3 & 4

  • 4]

    3 & 2

Solution
8
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
9
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
10
Discuss

What will be the output of the following Java program?

    class leftshift_operator 
    {
        public static void main(String args[]) 
        {        
             byte x = 64;
             int i;
             byte y; 
             i = x << 2;
             y = (byte) (x << 2)
             System.out.print(i + " " + y);
        } 
    }

 

  • 1]

    0 64

  • 2]

    64 0

  • 3]

    0 256

  • 4]

    256 0

Solution
# Quiz