NEW
Font size
WorksheetsJava MCQs Worksheet
Total questions: 50
Worksheet time: 25mins
Java was originally developed by
Microsoft
Sun Microsystems
IBM
Oracle
Java is primarily known as a
Low-level language
Assembly language
Platform-independent language
Machine-dependent language
Which component makes Java platform independent?
JDK
JRE
JVM
JIT
The Java source file extension is
.jav
.class
.java
.exe
The Java compiler converts source code into
Machine code
Bytecode
Assembly code
Object code
Bytecode is executed by
Compiler
Editor
JVM
Loader
The default value of an int instance variable is
null
1
0
Undefined
Which of the following is not a Java feature?
Object-oriented
Secure
Portable
Pointer-based
Which keyword is used to define a constant in Java?
static
constant
final
define
The entry point of a Java program is
start()
init()
main()
run()
Which of the following is a valid main method signature?
public static void main(String args[])
static public int main()
void main(String[])
public void main()
Which operator is used for logical AND?
&
&&
|
||
Which loop executes at least once?
for
while
do-while
foreach
Which control statement is used for multiple branching?
if
if-else
switch
break
Type casting from int to double is
Explicit conversion
Narrowing conversion
Implicit conversion
Invalid
Which data type occupies 8 bytes?
int
float
double
short
Command line arguments are accessed using
Scanner
BufferedReader
args[]
System.in
Which symbol is used to access array elements?
()
{}
<>
[]
Arrays in Java are
Fixed size
Dynamic size
Resizable automatically
Pointer-based
Array index starts from
-1
0
1
Depends on array
Which statement stops loop execution?
continue
break
exit
stop
Which operator is used to compare two values?
=
==
!=
Both B and C
Which of the following is a unary operator?
+
-
++
*
JVM stands for
Java Visual Machine
Java Virtual Machine
Java Verified Machine
Java Variable Machine
Java programs are
Interpreted only
Compiled only
Compiled and interpreted
Assembled
A class in Java is a
Variable
Function
Blueprint of an object
Package
An object is an instance of a
Package
Method
Constructor
Class
Which keyword is used to create an object?
class
object
new
this
A constructor is used to
Destroy objects
Initialize objects
Call methods
Create variables
Constructor name must be same as
Method name
Variable name
Class name
Package name
Constructors do not have
Parameters
Return type
Overloading
Access modifiers
Method overloading is based on
Return type
Method name
Parameter list
Access specifier
Which keyword refers to the current object?
super
static
final
this
Static members belong to
Object
Method
Class
Constructor
Final variable value
Can change
Cannot change
Changes at runtime
Is optional
Which class is immutable?
String
StringBuffer
StringBuilder
StringTokenizer
String objects are stored in
Heap only
Stack
String Constant Pool
Register
Which method compares string content?
==
equals()
compareTo()
Both B and C
StringBuffer is
Immutable
Thread-safe
Non-synchronized
Faster than StringBuilder
StringBuilder is
Thread-safe
Synchronized
Immutable
Non-synchronized
Which class is used to break strings into tokens?
Scanner
Split
StringTokenizer
Token
The default constructor is provided by
Programmer
JVM
Compiler
JRE
Constructor overloading allows
Same name, same parameters
Different name, same parameters
Same name, different parameters
Different return types
Which keyword prevents inheritance?
static
final
private
protected
Which method returns string length?
size()
length()
count()
getLength()
Which operator concatenates strings?
*
&
+
%
Which keyword is used to define a class member shared by all objects?
final
static
this
super
Which of the following is mutable?
String
StringBuilder
Integer
Character
Object creation always involves
Method call
Constructor call
Static block
Final variable
Which class is faster for single-threaded operations?
String
StringBuffer
StringBuilder
StringTokenizer
