NEW
Font size
WorksheetsJava Programming Quiz
Total questions: 30
Worksheet time: 15mins
Which of the following is not a feature of Java?
Platform independence
Object-oriented
Pointers
Robust
JVM stands for:
Java Variable Machine
Java Virtual Machine
Java Visual Method
Java Verified Machine
Which of the following correctly describes JDK?
It is used to develop and run Java applications.
It is only for compiling Java programs.
It provides only the runtime environment.
It contains only the JVM.
Java was originally developed by:
Microsoft
Sun Microsystems
IBM
The extension of compiled Java bytecode file is:
.java
.class
.jar
.exe
Which method is the entry point for every Java application?
start()
run()
main()
execute()
Which of the following is a valid Java identifier?
123num
num_1
num-1
public
Which data type is used to create a variable that stores text?
String
char
boolean
int
Which operator is used to compare two values in Java?
=
==
:=
equals()
Which keyword is used to define a constant in Java?
const
constant
static
final
What will happen if you do not initialize a local variable in Java?
It will have a default value.
Compilation error.
Runtime error.
It will be initialized to zero.
Which statement is used to exit from a loop in Java?
stop
exit
break
return
Which keyword is used to inherit a class in Java?
implements
extends
inherits
super
What is the purpose of the 'super' keyword?
To call subclass methods
To refer to the parent class object
To define static methods
To define constructors
Which method is used to compare two strings in Java?
==
compareTo()
equalsTo()
equals()
Which of these supports multiple inheritance in Java?
Classes
Interfaces
Abstract classes
Constructors
Abstract classes in Java can have:
Only abstract methods
Only concrete methods
Both abstract and concrete methods
No methods
Which access specifier allows visibility within the same package only?
private
public
protected
default
What does the keyword 'final' prevent when used with a class?
Method overriding
Inheritance
Object creation
Garbage collection
How can you import all classes in a package?
import package.;
include package.;
use package.;
import.;
Which block is always executed regardless of exception?
try
catch
throw
finally
Which exception occurs when dividing by zero?
IOException
ArithmeticException
NullPointerException
NumberFormatException
Which statement is used to manually throw an exception?
throws
try
throw
catch
Checked exceptions are:
Detected at runtime
Detected at compile-time
Ignored by the compiler
None of the above
Which interface must a class implement to create a thread?
Thread
Runnable
Executable
Main
Which method starts the execution of a thread?
run()
start()
execute()
begin()
Which of these methods can stop a running thread?
wait()
terminate()
stop()
exit()
Which method is used for inter-thread communication?
communicate()
wait(), notify(), notifyAll()
run(), start()
sleep(), resume()
What is the default priority of a thread in Java?
1
5
10
0
Which of the following is used to synchronize threads in Java?
synchronized keyword
volatile keyword
static keyword
const keyword
