Quiz Discussion

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

 

Course Name: Java

  • 1]

    5.640000000000001 5

  • 2]

    5.640000000000001 5.0

  • 3]

    5 5

  • 4]

    5 5.640000000000001

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

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

 

  • 1]

    3 1 6

  • 2]

    2 2 3

  • 3]

    2 3 4

  • 4]

    3 3 6

Solution
2
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
3
Discuss

Which of these operators can skip evaluating right hand operand?

  • 1]

    !

  • 2]

    |

  • 3]

    &

  • 4]

    &&

Solution
4
Discuss

Which of these have highest precedence?

  • 1]

    ()

  • 2]

    ++

  • 3]

    *

  • 4]

    >>

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

Which of these statements are incorrect?

  • 1]

    The left shift operator, <<, shifts all of the bits in a value to the left specified number of times

  • 2]

    The right shift operator, >>, shifts all of the bits in a value to the right specified number of time

  • 3]

    The left shift operator can be used as an alternative to multiplying by 2

  • 4]

    The right shift operator automatically fills the higher order bits with 0

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

What will be the output of the following Java program?

    class bitwise_operator 
    {
        public static void main(String args[]) 
        {    
             int a = 3;
             int b = 6;
 	         int c = a | b;
             int d = a & b;             
             System.out.println(c + " "  + d);
        } 
    }

 

  • 1]

    7 2

  • 2]

    7 7

  • 3]

    7 5

  • 4]

    5 2

Solution
9
Discuss

What is the order of precedence (highest to lowest) of following operators?

    1. &    
    2. ^
    3. ?:
  • 1]

    1 -> 2 -> 3

  • 2]

    2 -> 1 -> 3

  • 3]

    3 -> 2 -> 1

  • 4]

    2 -> 3 -> 1

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