Quiz Discussion

Which of these statements is correct?

Course Name: Java

  • 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
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

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

 

  • 1]

    3 2 4

  • 2]

    3 2 3

  • 3]

    2 3 4

  • 4]

    3 4 4

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

What will be the output of the following Java code?

    class Output 
    {
        public static void main(String args[]) 
        {    
             boolean a = true;
             boolean b = false;
             boolean c = a ^ b;
             System.out.println(!c);
        } 
    }

 

  • 1]

    0

  • 2]

    1

  • 3]

    true

  • 4]

    false

Solution
7
Discuss

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

  • 1]

    true

  • 2]

    false

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