Quiz Discussion

What is the valid data type for variable “a” to print “Hello World”?

switch(a)
{
   System.out.println("Hello World");
}

 

Course Name: Java

  • 1]

    int and float

  • 2]

    byte and short

  • 3]

    char and long

  • 4]

    byte and char

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 these selection statements test only for equality?

  • 1]

    if

  • 2]

    switch

  • 3]

    if & switch

  • 4]

    none of the mentioned

Solution
2
Discuss

Which of this statement is incorrect?

  • 1]

    switch statement is more efficient than a set of nested ifs

  • 2]

    two case constants in the same switch can have identical values

  • 3]

    switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression

  • 4]

    it is possible to create a nested switch statements

Solution
3
Discuss

What will be the output of the following Java program?

    class Output 
    {
        public static void main(String args[]) 
        {    
             int a = 5;
             int b = 10;
             first: 
             {
                second: 
                {
                   third: 
                   { 
                       if (a ==  b >> 1)
                           break second;
                   }
                   System.out.println(a);
                }
                System.out.println(b);
             }
        } 
    }

 

  • 1]

    5 10

  • 2]

    10 5

  • 3]

    5

  • 4]

    10

Solution
# Quiz