NEW
Font size
WorksheetsJava Basics
Total questions: 17
Worksheet time: 6mins
Java is short for "JavaScript".
true
false
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?
myString
String
Txt
string
How do you create a variable with the numeric value 5?
float x = 5;
x = 5;
int x = 5;
num x = 5
How do you create a variable with the floating number 2.8?
byte x = 2.8f
x = 2.8f;
float x = 2.8f;
int x = 2.8f;
Which method can be used to find the length of a string?
getSize()
getLength()
length()
len()
Which operator is used to add together two values?
The + sign
The * sign
The & sign
The value of a string variable can be surrounded by single quotes.
true
false
Which operator can be used to compare two values?
><
=
==
<>
To declare an array in Java, define the variable type with:
{}
[]
()
Array indexes start with:
0
1
How do you create a method in Java?
methodName()
(methodName)
methodName[]
methodName.
How do you call a method in Java?
methodName;
methodName[];
methodName();
(methodName);
Which method can be used to find the highest value of x and y?
Math.largest(x,y)
Math.max(x,y)
Math.maximum(x,y)
Math.maxNum(x,y)
Which keyword is used to import a package from the Java API library?
import
lib
getlib
package
Which keyword is used to return a value inside a method?
return
void
break
get
Which statement is used to stop a loop?
exit
stop
return
break
