Quiz Discussion

What will be the output of the following Java program?

    class Output 
    {
        public static void main(String args[]) 
        {    
             int a = 1;
             int b = 2;
             int c;
             int d;
             c = ++b;
             d = a++;
             c++;
             b++;
             ++a;
             System.out.println(a + " " + b + " " + c);
        } 
    }

 

Course Name: Java

  • 1]

    3 2 4

  • 2]

    3 2 3

  • 3]

    2 3 4

  • 4]

    3 4 4

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 the following can be operands of arithmetic operators?

  • 1]

    Numeric

  • 2]

    Boolean

  • 3]

    Characters

  • 4]

    Both Numeric & Characters

Solution
2
Discuss

 On applying Left shift operator, <<, on integer bits are lost one they are shifted past which position bit?

  • 1]

    1

  • 2]

    32

  • 3]

    33

  • 4]

    31

Solution
3
Discuss

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

 

  • 1]

    24 8

  • 2]

    24 9

  • 3]

    27 8

  • 4]

    27 9

Solution
4
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
5
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
6
Discuss

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

  • 1]

    true

  • 2]

    false

Solution
7
Discuss

What will be the output of the following Java program?

    class bitwise_operator 
    {
        public static void main(String args[])
        {
            int var1 = 42;
            int var2 = ~var1;
            System.out.print(var1 + " " + var2);     	
        } 
    }

 

  • 1]

    42 42

  • 2]

    43 43

  • 3]

    42 -43

  • 4]

    42 43

Solution
8
Discuss

 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;
  • 1]

    0

  • 2]

    1

  • 3]

    9

  • 4]

    8

Solution
9
Discuss

Which of these have highest precedence?

  • 1]

    ()

  • 2]

    ++

  • 3]

    *

  • 4]

    >>

Solution
10
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
# Quiz