placeholder image to represent content

In java for loop, while loop , data types, if else , if , switch case

Quiz by Balveer Kaur

Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

New Quizalize solo game modes
20 questions
Show answers
  • Q1
    What is the correct syntax for a for loop in Java?
    while (condition) { }
    for (condition; initialization; update) { }
    for (initialization; condition; update) { }
    do { } while (condition)
    30s
  • Q2
    What is the purpose of an 'if else' statement in Java?
    To store a single value in memory.
    To declare a new variable in Java.
    To repeat a block of code until a condition is met.
    To execute a block of code if a specified condition is true, and a different block of code if the condition is false.
    30s
  • Q3
    Which data type in Java is used to store whole numbers?
    boolean
    String
    double
    int
    30s
  • Q4
    What is the purpose of a 'switch case' statement in Java?
    To store a single value in memory.
    To repeat a block of code until a condition is met.
    To declare a new variable in Java.
    To execute different blocks of code based on the value of a variable or expression.
    30s
  • Q5
    What is the purpose of a 'while loop' in Java?
    To repeatedly execute a block of code as long as a specified condition is true.
    To execute a block of code only if a condition is true.
    To define a specific case for a given input.
    To select different code blocks based on a variable's value.
    30s
  • Q6
    What is the syntax for an 'if' statement in Java?
    if {condition} then { }
    if (condition) { }
    if (condition) then { }
    condition { if }
    30s
  • Q7
    What will be the output of the following Java code snippet?
    11
    10
    12
    15
    30s
  • Q8
    What does the 'break' keyword do in a switch case statement?
    It moves to the next case block within the switch statement.
    It exits the switch case statement, stopping the execution of the subsequent code blocks.
    It restarts the current case block within the switch statement.
    It ends the entire program execution.
    30s
  • Q9
    What is the difference between a 'for' loop and a 'while' loop in Java?
    A 'for' loop cannot iterate over arrays, while a 'while' loop can.
    A 'for' loop is typically used when the number of iterations is known, while a 'while' loop is used when the number of iterations is unknown.
    A 'for' loop can only be used to iterate through strings, while a 'while' loop can handle other data types.
    A 'for' loop allows for incrementing a loop variable, while a 'while' loop does not.
    30s
  • Q10
    What is the correct syntax for declaring a variable of type 'double' in Java?
    variableName double;
    double variableName;
    double variableName = 0;
    variableName = double;
    30s
  • Q11
    Which data type in Java is used to hold whole numbers?
    String
    int
    double
    float
    30s
  • Q12
    What is the keyword used to start a loop that continues as long as a specified condition is true in Java?
    switch
    while
    if
    for
    30s
  • Q13
    Which keyword in Java is used to make a decision based on a condition?
    switch
    if
    while
    for
    30s
  • Q14
    Which keyword in Java is used to perform different actions based on different conditions?
    switch
    while
    if
    for
    30s
  • Q15
    Which loop in Java is used for iterating over a range of values?
    do-while
    while
    switch
    for
    30s

Teachers give this quiz to your class