WorksheetsJava Concepts Challenge
Total questions: 10
Worksheet time: 5mins
What is the default value of a boolean variable in Java?
false
null
true
undefined
Which of the following is not a primitive data type in Java?
Integer
String
Character
Float
What is the output of the following code: System.out.println(5 + 3 + "Hello");?
3Hello5
8Hello
Hello8
5Hello3
What keyword is used to create a subclass in Java?
extends
inherits
implements
derives
Which of the following is a valid declaration of a method in Java?
void myMethod()
public myMethod()
public void myMethod()
private void myMethod()
What is the output of the following code: int x = 10; System.out.println(x++);?
10.0
9
10
11
What is encapsulation in Java?
Encapsulation is the use of interfaces to define method signatures.
Encapsulation is the process of converting data types into objects.
Encapsulation is the separation of classes into different packages.
Encapsulation is the bundling of data and methods that operate on that data, restricting direct access to some components.
Which of the following statements is true about constructors in Java?
Constructors can have different names from the class.
Constructors must always return a value.
Constructors can be private and have no parameters.
Constructors in Java have the same name as the class and do not have a return type.
What will be the output of the following code: System.out.println("Hello".length());?
7
6
5
4
What is the purpose of the 'this' keyword in Java?
The 'this' keyword refers to the current instance of a class.
The 'this' keyword is a way to declare variables.
The 'this' keyword refers to a superclass instance.
The 'this' keyword is used for static methods.
