WorksheetsMastering Java Basics
Total questions: 8
Worksheet time: 4mins
What is the correct way to declare a variable in Java?
var variableName int;
float variableName = 0;
string variableName;
int variableName;
How do you print a string to the console in Java?
console.log('Your string here');
print('Your string here');
System.out.println("Your string here");
echo 'Your string here';
Which of the following is a valid Java data type?
int
float
boolean
string
What symbol is used to end a statement in Java?
;
!
:
.
How do you create a single-line comment in Java?
# This is a comment
/* This is a comment */
// This is a single-line comment
-- This is a comment
What is the output of System.out.println(5 + 3);?
6
8
10
9
What keyword is used to define a class in Java?
define
object
class
function
What is the result of System.out.println("Hello" + " World");?
HelloWorld
Hello, World
Hello World!
Hello World
