In java for loop, while loop , data types, if else , if , switch case
Quiz by Balveer Kaur
Feel free to use or edit a copy
includes Teacher and Student dashboards
Measure skillsfrom any curriculum
Measure skills
from any curriculum
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
With a free account, teachers can
- edit the questions
- save a copy for later
- start a class game
- automatically assign follow-up activities based on students’ scores
- assign as homework
- share a link with colleagues
- print as a bubble sheet
20 questions
Show answers
- Q1What is the correct syntax for a for loop in Java?while (condition) { }for (condition; initialization; update) { }for (initialization; condition; update) { }do { } while (condition)30s
- Q2What 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
- Q3Which data type in Java is used to store whole numbers?booleanStringdoubleint30s
- Q4What 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
- Q5What 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
- Q6What is the syntax for an 'if' statement in Java?if {condition} then { }if (condition) { }if (condition) then { }condition { if }30s
- Q7What will be the output of the following Java code snippet?1110121530s
- Q8What 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
- Q9What 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
- Q10What is the correct syntax for declaring a variable of type 'double' in Java?variableName double;double variableName;double variableName = 0;variableName = double;30s
- Q11Which data type in Java is used to hold whole numbers?Stringintdoublefloat30s
- Q12What is the keyword used to start a loop that continues as long as a specified condition is true in Java?switchwhileiffor30s
- Q13Which keyword in Java is used to make a decision based on a condition?switchifwhilefor30s
- Q14Which keyword in Java is used to perform different actions based on different conditions?switchwhileiffor30s
- Q15Which loop in Java is used for iterating over a range of values?do-whilewhileswitchfor30s