NEW
Font size
WorksheetsBasic Java Quiz
Total questions: 15
Worksheet time: 5mins
What type of language is Java?
Object Oriented
Scripting
Assembly
Pseudocode
What is the default value of an int variable in Java?
0
1
null
-1
Which keyword is used to create an object in Java?
create
object
new
make
What is the correct way to declare a variable of type double in Java?
double variableName
boolean variableName
String variableName
int variableName
What is the output of the following code? int x = 5; System.out.println(x++);
6
null
5
4
What is the output of the following code? String str = "Java"; System.out.println(str.length());
6
3
5
4
What is the output of the following code? System.out.println(10 > 5 && 5 < 3);
5
true
false
10
What is the correct way for storing WHOLE numbers in Java?
float num = 5.0
int num = 5;
double num = 5.0
string num = "5";
What is the output of z?
int x = 5;
int y = 2;
int z = x/y;
2.5
2.50
2
ERROR
Which of the loops is guaranteed to execute at least once?
for loop
while loop
do-while loop
enhanced while loop
Which of the following is a valid way to make a comment in Java?
#this is a comment
"""This is a comment
**This is a comment
//This is a comment
Which one is the proper format for a multi-line comment in Java?
//
Hello
World
//
*/
Hello
World
/*
/*
Hello
World
*/
There's no such thing
What is the format for the main method in Java?
public static void double(string[] args)
public void static main(String[] args)
private static void main(String[] args)
public static void main(String[] args)
Which of the following data types stores characters in Java?
int
double
char
boolean
What is the output?
for (int i = 0; i < 3; i++) {
System.out.print(i + " ");
}
0 1 2 3
0 1 2 3 4
0 1 2
0 1
