Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
Q 1/33
Score 0
Which of the following is NOT a primitive data type in Java?
30
double
int
boolean
String
Q 2/33
Score 0
What is the output of the following Java code?```int x = 5;int y = 10;int z = x + y;System.out.println(z);```
30
10
20
15
5
Q 3/33
Score 0
What is the purpose of the `public` access modifier in Java?
30
To enable inheritance of a member to subclasses
To make a member accessible from any other part of the program
To provide encapsulation of a member
To restrict access to a member within its own class
Q 4/33
Score 0
Which of the following is an example of an object-oriented programming (OOP) principle in Java?
30
Loops
Functions
Conditionals
Inheritance
Q 5/33
Score 0
What is the purpose of the `break` statement in a Java switch statement?
30
To exit the switch block and continue executing the code after the switch
To skip the current case and move to the next case
To execute a default case
To terminate the entire program
Q 6/33
Score 0
What is the syntax to declare and initialize an array of integers in Java?
30
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};
Q 7/33
Score 0
Which of the following is NOT a valid identifier name in Java?
30
_abc
my_variable
$abc
myVariable
123abc
Q 8/33
Score 0
Which operator is used to compare two values for equality in Java?
30
!=
==
=
===
Q 9/33
Score 0
Which operator is used to perform the modulo operation in Java?
30
%
*
+
/
Q 10/33
Score 0
Which of the following loops in Java is used when the number of iterations is known?
30
do-while loop
while loop
enhanced for loop
for loop
Q 11/33
Score 0
What is the purpose of the do-while loop in Java?
30
To iterate over elements of an array or collection
To execute a block of code a specific number of times
To handle exceptions
To execute a block of code at least once and then repeat it based on a condition
Q 12/33
Score 0
What is the syntax for a basic for loop in Java?
30
for (initialization; condition; update) { // code block }
for (condition; initialization; update) { // code block }
for (condition; update; initialization) { // code block }
for (update; initialization; condition) { // code block }
Q 13/33
Score 0
What does the continue statement do in a loop?
30
Modifies the loop condition
Terminates the loop prematurely
Skips the current iteration and moves to the next iteration
Restarts the loop from the beginning
Q 14/33
Score 0
What is the difference between the prefix increment operator (++i) and the postfix increment operator (i++) in a loop?
30
The prefix increment operator increments the value of the variable before using it, while the postfix increment operator uses the current value and then increments
The prefix increment operator only works with integer variables, while the postfix increment operator works with any data type
The 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 itself
There is no difference between the prefix and postfix increment operators in a loop
Q 15/33
Score 0
What is the default value of the boolean data type in Java?
30
false
null
true
0
false
Q 16/33
Score 0
Which of the following is not a valid Java data type for storing decimal numbers?
30
double
char
BigDecimal
float
char
Q 17/33
Score 0
What is the size of the 'double' data type in Java?
30
8 bytes
8 bytes
16 bytes
4 bytes
2 bytes
Q 18/33
Score 0
How do you access the value at a specific index in a Java array?
30
arrayName[index]
arrayName.get(index)
arrayName.getValue(index)
arrayName.value(index)
Q 19/33
Score 0
How do you initialize and assign values to an array in Java?
30
int[] numbers = {1, 2, 3, 4, 5}
int numbers[5] = {1, 2, 3, 4, 5}
int numbers[] = {1, 2, 3, 4, 5}
int[] numbers = new int[5]
Q 20/33
Score 0
What is the correct syntax to access the last element in a Java array?
30
arrayName[arrayName.length + 1]
arrayName[arrayName.length]
arrayName[arrayName.length - 1]
arrayName[arrayName.size() - 1]
Q 21/33
Score 0
How do you resize a Java array?
30
Using the resizeArray() method
Using the resize() method
You cannot resize a Java array once it is initialized
Using the Arrays.resize() method
Q 22/33
Score 0
How do you find the minimum value in a Java array?
30
Using the getMin() method
Using a loop to compare each element
Using the min() method
Using the Arrays.min() method
Q 23/33
Score 0
What is the correct syntax to declare a constructor in Java?
30
ClassName() {}
void className(parameters) {}
public ClassName(parameters) {}
public void ClassName(parameters) {}
Q 24/33
Score 0
What is the output of the following code snippet?public class MyClass { public static void main(String[] args) { int x = 5; int result = x * 2 + 10; System.out.println(result); }}
30
15
25
30
20
Q 25/33
Score 0
Which keyword is used to inherit a class in Java?
30
inherits
extends
implements
inheritsFrom
Q 26/33
Score 0
What is the purpose of the 'final' keyword in Java?
30
It is used to declare a constant variable.
It enables multiple classes to inherit a single superclass.
It indicates that a variable or method cannot be overridden or modified.
It allows a class to implement multiple interfaces.
Q 27/33
Score 0
What is the purpose of the 'this' keyword in Java?
30
It is used to define a static method.
It is used to create an object of a class.
It refers to the current instance of a class.
It is used to declare a variable with global scope.
Q 28/33
Score 0
What is the file extension for Java source code files?
30
.cpp
.js
.py
.java
Q 29/33
Score 0
Which keyword is used to declare a method that does not return any value?
30
String
void
double
int
Q 30/33
Score 0
What is the correct syntax to declare a variable in Java?
30
variableName = datatype
variableName = datatype;
datatype variableName;
datatype = variableName;
int variableName;
Q 31/33
Score 0
Which keyword is used to create an instance of a class in Java?
30
create
new
instanceof
instantiate
Q 32/33
Score 0
What is the output of the following Java code?int x = 5;int y = 2;int result = x / y;System.out.println(result);
30
3
2
2.5
2.0
Q 33/33
Score 0
What is the main purpose of a constructor in Java?
30
To initialize object properties/variables
To define class methods
To declare variables
To perform mathematical calculations
33 questions
Q.Which of the following is NOT a primitive data type in Java?
1
30 sec
Q.What is the output of the following Java code?```int x = 5;int y = 10;int z = x + y;System.out.println(z);```
2
30 sec
Q.What is the purpose of the `public` access modifier in Java?
3
30 sec
Q.Which of the following is an example of an object-oriented programming (OOP) principle in Java?
4
30 sec
Q.What is the purpose of the `break` statement in a Java switch statement?
5
30 sec
Q.What is the syntax to declare and initialize an array of integers in Java?
6
30 sec
Q.Which of the following is NOT a valid identifier name in Java?
7
30 sec
Q.Which operator is used to compare two values for equality in Java?
8
30 sec
Q.Which operator is used to perform the modulo operation in Java?
9
30 sec
Q.Which of the following loops in Java is used when the number of iterations is known?
10
30 sec
Q.What is the purpose of the do-while loop in Java?
11
30 sec
Q.What is the syntax for a basic for loop in Java?
12
30 sec
Q.What does the continue statement do in a loop?
13
30 sec
Q.What is the difference between the prefix increment operator (++i) and the postfix increment operator (i++) in a loop?
14
30 sec
Q.What is the default value of the boolean data type in Java?
15
30 sec
Q.Which of the following is not a valid Java data type for storing decimal numbers?
16
30 sec
Q.What is the size of the 'double' data type in Java?
17
30 sec
Q.How do you access the value at a specific index in a Java array?
18
30 sec
Q.How do you initialize and assign values to an array in Java?
19
30 sec
Q.What is the correct syntax to access the last element in a Java array?
20
30 sec
Q.How do you resize a Java array?
21
30 sec
Q.How do you find the minimum value in a Java array?
22
30 sec
Q.What is the correct syntax to declare a constructor in Java?
23
30 sec
Q.What is the output of the following code snippet?public class MyClass { public static void main(String[] args) { int x = 5; int result = x * 2 + 10; System.out.println(result); }}
24
30 sec
Q.Which keyword is used to inherit a class in Java?
25
30 sec
Q.What is the purpose of the 'final' keyword in Java?
26
30 sec
Q.What is the purpose of the 'this' keyword in Java?
27
30 sec
Q.What is the file extension for Java source code files?
28
30 sec
Q.Which keyword is used to declare a method that does not return any value?
29
30 sec
Q.What is the correct syntax to declare a variable in Java?
30
30 sec
Q.Which keyword is used to create an instance of a class in Java?
31
30 sec
Q.What is the output of the following Java code?int x = 5;int y = 2;int result = x / y;System.out.println(result);
32
30 sec
Q.What is the main purpose of a constructor in Java?