WorksheetsDsquad
Total questions: 10
Worksheet time: 5mins
What keyword is used to create an object in Java?
create
new
objectify
instance
What does System.out.println("Hello, World!"); do?
What does the 'int' keyword represent in Java?
It defines a string variable.
It represents an integer data type.
It is used for floating-point numbers.
It indicates a boolean value.
What is the purpose of the 'public' keyword in Java?
It restricts access to the class.
It allows access from any other class.
It indicates a private variable.
It is used for static methods only.
Which of these is NOT a valid Java identifier? (AKA variable name)
_myVariable
$javaRocks
2cool4Java
camelCaseIsLife
What does the 'void' keyword signify in a method declaration?
It indicates that the method returns no value.
It means the method will return an integer.
It specifies that the method is private.
It allows the method to return multiple values.
What is the function of the 'for' loop in Java?
It creates an infinite loop.
It defines a new class.
It is used to declare variables.
It executes a block of code a specific number of times.
What happens if you forget a semicolon (;) in Java?
Java forgives you
Your code runs but with a warning
Compilation error, sadness follows
It fixes itself magically
How many objects are created in this line? String str1 = new String("Java"); String str2 = "Java";
1
2
3
4
What is the output of boolean isJavaFun = true; System.out.println(isJavaFun);?
Yes
No
true
false
