Quiz Discussion

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

 

Course Name: Java

  • 1]

    0 64

  • 2]

    64 0

  • 3]

    0 256

  • 4]

    256 0

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

Can 8 byte long data type be automatically type cast to 4 byte float data type?

  • 1]

    true

  • 2]

    false

Solution
2
Discuss

Modulus operator, %, can be applied to which of these?

  • 1]

    Integers

  • 2]

    Floating – point numbers

  • 3]

    Both Integers and floating – point numbers

  • 4]

    None of the mentioned

Solution
3
Discuss

What is the output of relational operators?

  • 1]

    Integer

  • 2]

    Boolean

  • 3]

    Characters

  • 4]

    Double

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 code?

class Output 
{
        public static void main(String args[]) 
        {    
             int x=y=z=20;
 
        } 
}

 

  • 1]

    compile and runs fine

  • 2]

    20

  • 3]

    run time error

  • 4]

    compile time error

Solution
6
Discuss

Which of the following can be operands of arithmetic operators?

  • 1]

    Numeric

  • 2]

    Boolean

  • 3]

    Characters

  • 4]

    Both Numeric & Characters

Solution
7
Discuss

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

 

  • 1]

    false false

  • 2]

    true ture

  • 3]

    true false

  • 4]

    false true

Solution
8
Discuss

Which of these statements is correct?

  • 1]

    true and false are numeric values 1 and 0

  • 2]

    true and false are numeric values 0 and 1

  • 3]

    true is any non zero value and false is 0

  • 4]

    true and false are non numeric values

Solution
9
Discuss

Which of these is not a bitwise operator?

  • 1]

    &

  • 2]

    &=

  • 3]

    |=

  • 4]

    <=

Solution
10
Discuss

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

 

  • 1]

    10

  • 2]

    11

  • 3]

    12

  • 4]

    56

Solution
# Quiz