Site icon DataFlair

Quiz on Decision Making in Java

quiz on decision making in java

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Put your decision-making skills to the test with this comprehensive quiz on one of Java’s most essential concepts! Whether you’re a budding coder or a seasoned developer, this engaging challenge will help you solidify your understanding of conditional statements, control the flow of your programs, and make confident coding choices.

Delve into questions that explore if statements, else clauses, nested conditions, and more. Gear up to tackle different scenarios and make Java work for you!

Time limit: 0

Quiz Summary

0 of 15 Questions completed

Questions:

Information

You have already completed the quiz before. Hence you can not start it again.

Quiz is loading…

You must sign in or sign up to start the quiz.

You must first complete the following:

Results

Quiz complete. Results are being recorded.

Results

0 of 15 Questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 point(s), (0)

Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)

Categories

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 15
    1. Question

    class IfExample {

    public  static void main ( String args [ ] ) 

    {

    Scanner s = new Scanner(System.in);

    int a = s.nextInt();

    if(a==7) {

    system.out.println(“ If statement is executed “);

    }

    }

    }

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

     class IfElseSample {

    public static void main ( String args [ ] ) 

    {

    String s = “ DataFlair”;

    Char d [ ] = { ‘D’ , ‘a’, ‘t’, ‘a’ , ‘F’ , ‘l’ , ‘a’ , ‘i’ , ‘r’ };

    String a = new String(d);

    if(s.isequals(a)) {

    system.out.println(“Two strings are equal”);

    } else {

    system.out.println(“Two strings are not equal”);

    }

    }

    }

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

    Which of the following is the right syntax for a nested if loop ?

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

    class Sample {

    public static void main ( String args [ ]  ) 

    {

    int a = 4 ;

    if( a < 10 ) {

    if ( a < 5 ) {

    system.out.println(“The number is also less than 5 “);

    }else {

    system.out.println(“The number is less than 10 alone “);

    }

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

     If the input value from the user does not match with any case statements in the switch case , which block of statement will be executed ?

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

     class SwitchExample {

    public static void main ( String args [ ] )

    {

    int a = 5 ;

    switch(a) 

    {

    case 5: 

    {

    system.out.println(“Number is 5 “);

    }

    case 6:

    {

    system.out.println(“Number is not a 5 “);

    }

    Default:

    {

    system.out.println(“It is an unknown number”);

    }

    }

    }

    }

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

    class Demo {

    public static void main ( String args [ ] )

    {

    int x = 0;

    switch(x)

    {

    case 0 :

    {

    system.out.println(“The number is 0 “);

    break;

    }

    case 1:

    {

    system.out.println(“The number is not zero “);

    break;

    }

    }

         }

    }

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

     Which of the following is true about the switch case ?

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question

    class SwitchCaseSample {

    public static void main ( String args [ ] )

    {

    float pi =  3.14;

    switch(pi)

    {

    case 3.14:

    {

    system.out.println(“This is the value of PI “);

    break;

    }

    default:

    {

    system.out.println(“This is not the value of PI”);

    break;

    }

    }

    }

    }

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question

    Which of the following is the correct syntax of a switch case in Java ?

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

     class ReturnStatement {

    public static void main ( String args [ ] )

    {

    int a = 10;

    if(a == 10) {

    system.out.println(a);

    return;

    ++a;

    system.out.println(a);

    }

    }

    }

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

    class ContinueStatement {

    public static void main( String args [ ] ) {

    int [ ] marks = {88 , 89 , 29 , 91 , 92};

    for(int x : marks ) {

    if( x <= 35 ) {

                continue;

             }

    system.out.println(“Subjects passed are :”);

    System.out.print( x );

                }

    }

    }

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

    When there will be a compile time error in the if statement?

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

    class NestedIf {

    public static void main ( String args [ ] ) 

    {

    int a = 8;

    if(a<10) {

    if(a<=8) {

    if(a<8){

    system.out.println(“ Number is less than 8 “);

    }

    system.out.println(“Number is less than or equal to 8”);

    }

    system.out.println(“Number is greater than 10);

    }

    }

    }

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

     Which of the following statements is more efficient than executing a long if else ladder?

    Correct
    Incorrect

Summary:

This interactive quiz has put those skills to the test, covering a range of decision-making concepts. By taking this quiz, you’ve actively engaged with different problem-solving scenarios, reinforcing your knowledge and identifying areas for further exploration.

Remember, continuous practice and exploration are key to mastering any programming language. Keep exploring, keep practising, and make those decisions count in your Java code!

Exit mobile version