Java
Quiz by Swathikaa Rk
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
33 questions
Show answers
- Q1Which of the following is NOT a primitive data type in Java?doubleintbooleanString30s
- Q2What is the output of the following Java code?```int x = 5;int y = 10;int z = x + y;System.out.println(z);```102015530s
- Q3What is the purpose of the `public` access modifier in Java?To enable inheritance of a member to subclassesTo make a member accessible from any other part of the programTo provide encapsulation of a memberTo restrict access to a member within its own class30s
- Q4Which of the following is an example of an object-oriented programming (OOP) principle in Java?LoopsFunctionsConditionalsInheritance30s
- Q5What is the purpose of the `break` statement in a Java switch statement?To exit the switch block and continue executing the code after the switchTo skip the current case and move to the next caseTo execute a default caseTo terminate the entire program30s
- Q6What is the syntax to declare and initialize an array of integers in Java?int[] numbers = [1, 2, 3, 4, 5];int[] numbers = {1, 2, 3, 4, 5};Array numbers = {1, 2, 3, 4, 5};int numbers = {1, 2, 3, 4, 5};30s
- Q7Which of the following is NOT a valid identifier name in Java?_abcmy_variable$abcmyVariable123abc30s
- Q8Which operator is used to compare two values for equality in Java?!=======30s
- Q9Which operator is used to perform the modulo operation in Java?%*+/30s
- Q10Which of the following loops in Java is used when the number of iterations is known?do-while loopwhile loopenhanced for loopfor loop30s
- Q11What is the purpose of the do-while loop in Java?To iterate over elements of an array or collectionTo execute a block of code a specific number of timesTo handle exceptionsTo execute a block of code at least once and then repeat it based on a condition30s
- Q12What is the syntax for a basic for loop in Java?for (initialization; condition; update) { // code block }for (condition; initialization; update) { // code block }for (condition; update; initialization) { // code block }for (update; initialization; condition) { // code block }30s
- Q13What does the continue statement do in a loop?Modifies the loop conditionTerminates the loop prematurelySkips the current iteration and moves to the next iterationRestarts the loop from the beginning30s
- Q14What is the difference between the prefix increment operator (++i) and the postfix increment operator (i++) in a loop?The prefix increment operator increments the value of the variable before using it, while the postfix increment operator uses the current value and then incrementsThe prefix increment operator only works with integer variables, while the postfix increment operator works with any data typeThe prefix increment operator increments the value of the variable and then assigns it to a new variable, while the postfix increment operator increments the original variable itselfThere is no difference between the prefix and postfix increment operators in a loop30s
- Q15What is the default value of the boolean data type in Java?falsenulltrue0false30s