NEW
Font size
WorksheetsBasic Java
Total questions: 15
Worksheet time: 8mins
What is a correct syntax to output "Hello World" in Java?
System.out.println("Hello World");
Console.WriteLine("Hello World");
echo("Hello World");
print ("Hello World");
Java is short for "JavaScript".
False
True
How do you insert COMMENTS in Java code?
// This is a comment
# This is a comment
/* This is a comment
Which data type is used to create a variable that should store text?
String
string
Txt
myString
How do you create a variable with the numeric value 5?
x = 5;
num x = 5
float x = 5;
int x = 5;
Which method can be used to find the length of a string?
len()
getLength()
length()
getSize()
The value of a string variable can be surrounded by single quotes.
False
True
Which operator can be used to compare two values?
==
=
<>
><
Array indexes start with:
1
0
How do you create a method in Java?
methodName.
methodName[]
methodName()
(methodName)
Which keyword is used to create a class in Java?
className
class
class()
MyClass
What is the correct way to create an object called myObj of MyClass?
new myObj = MyClass();
class MyClass = new myObj();
class myObj = new MyClass();
MyClass myObj = new MyClass();
How do you start writing a while loop in Java?
while x > y {
while (x > y)
while x > y:
x > y while {
Which statement is used to stop a loop?
return
break
stop
exit
Which keyword is used to import a package from the Java API library?
lib
import
getlib
package
