Question : 1 Which keyword is used to declare a class in Java?
class
void
public
new
Question : 2 Which data type is used to store whole numbers in Java?
int
String
double
char
Question : 3 What is the output of the following code snippet? ```java System.out.println(5 == 5); ```
true
false
error
0
Question : 4 Which method is called automatically when an object of a class is created?
run()
start()
main()
constructor
Question : 5 Which keyword is used to refer to the current instance of a class in Java?
this
super
self
current
Question : 6 What is the output of the following code snippet? ```java int x = 5; System.out.println(x++); ```
5
6
error
0
Question : 7 Which keyword is used to create a subclass in Java?
this
super
extends
class
Question : 8 Which of the following is NOT a valid Java identifier?
myVariable
2ndVariable
_myVariable
MyVariable123
Question : 9 Which operator is used to compare two values for equality in Java?
==
=
===
equals()
Question : 10 Which of the following statements is used to exit from a loop in Java?
break
continue
exit
return
Question : 11 Which keyword is used to define a constant value in Java?
static
final
constant
const
Question : 12 Which of the following access modifiers restricts access the least in Java?
private
protected
public
default
Question : 13 Which of the following is a type of loop in Java that is executed at least once?
for
while
do-while
foreach
Question : 14 What does the "static" keyword mean in Java?
Dynamic binding
Class level
Instance level
Shared among all instances of the class
Question : 15 Which of the following is not a valid type of variable in Java?
int
string
double
boolean
Question : 16 What is the result of 5 / 2 in Java?
2
2.5
2.0
2
Question : 17 Which method is called when an object is garbage collected in Java?
finalize()
destroy()
garbageCollector()
delete()
Question : 18 What is the purpose of the "toString()" method in Java?
Converts a string to uppercase
Converts a string to lowercase
Returns a string representation of an object
Concatenates two strings
Question : 19 What is the output of the following code snippet? ```java int[] numbers = {1, 2, 3, 4, 5}; System.out.println(numbers[3]); ```
1
2
3
4
Question : 20 Which keyword is used to prevent a method from being overridden in Java?
override
final
static
private
Question : 21 Which operator is used to concatenate strings in Java?
+
-
*
concat()
Question : 22 Which class is used to read input from the user in Java?
System.in
Scanner
Reader
InputStream
Question : 23 What is the result of the expression (5 > 3) && (8 < 5) in Java?
true
false
error
0
Question : 24 What is the output of the following code snippet? ```java String str = "hello"; System.out.println(str.charAt(2)); ```
e
l
h
o
Question : 25 Which statement is used to manually throw an exception in Java?
throw
throws
try
catch