wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JAVA QUIZ

Total questions: 170

Worksheet time: 1hrs 25mins

Name
Class
Date
1.
Who has developed Java language?
a)
Dennis Ritchie
b)
Bjarne Stroustrip
c)
James Ghosling
d)
Lichard
2.
Earlier java was called as
a)
Oak
b)
JDK
c)
Dynamic
d)
None of these
3.
Java is released in the year
a)
1972
b)
1995
c)
1969
d)
2000
4.
JDK expansion is
a)
Java Destination Kit
b)
J2EE Development Kit
c)
Java Development Kit
d)
None of these
5.
Java is ___ language
a)
Procedure Oriented
b)
Object Oriented
c)
Scrpting
d)
None of these
6.
Java language is ____________
a)
Procedure Oriented
b)
Platform dependent
c)
Platform Independent
d)
None of these
7.
Which of the following is not a features of Java?
a)
Robust
b)
Architectural Neutral
c)
Platform Independent
d)
Procedure Oriented
8.
WORA in Java indicates
a)
Write Once Run Anywhere
b)
Write Once Run Always
c)
Warning Order Run AnyTime
d)
With Out Run Anywhere
9.
JVM is used to execute ___________
a)
Java Source file
b)
Bytecode
c)
exe file
d)
None of these
10.
class or interface is ________ data type
a)
primitive
b)
non primitive
c)
base
d)
derived
11.
Which of the following represents 16 bit UNICODE character
a)
int
b)
char
c)
class
d)
array
12.
Which among following is not a primitive data type
a)
int
b)
boolean
c)
byte
d)
class
13.
Length of the data type byte in Java is
a)
16 bits
b)
1 bit
c)
8 bits
d)
4 bits
14.
Which of the following is not a valid keyword in C language?
a)
char
b)
boolean
c)
abstract
d)
robust
15.
Which among the following is not a looping keyword?
a)
while
b)
do
c)
for
d)
if
16.
The keyword which is used to exit from a loop is __________
a)
for
b)
while
c)
switch
d)
break
17.
The process of converting one data type into another type is called as
a)
Looping
b)
Type casting
c)
Buffering
d)
None of these
18.
Collection of elements of same data type is called as ____________
a)
Array
b)
Class
c)
Structure
d)
None of these
19.
int a[10]; can store maximum ______ number of elements
a)
20
b)
5
c)
10
d)
15
20.
int a[2][3]; can store maximum ____________ number opf elements
a)
5
b)
6
c)
2
d)
3
21.
The element in an array can be accessed using its
a)
Reference
b)
Index
c)
size
d)
length
22.
byte a[10]; Here the size of array variable " a " is
a)
80 bits
b)
100 bits
c)
10 bits
d)
None of these
23.
Which of the following acees specifier reperesents visibility to all?
a)
public
b)
private
c)
protected
d)
None of these
24.
The _____ keyword represents that the function does not return any value
a)
static
b)
void
c)
int
d)
System
25.
The _____ keyword is used to define a class.
a)
public
b)
String
c)
class
d)
None of these
26.
Which of the following is an example for Unary Operator
a)
Increment
b)
Relational
c)
Logical
d)
Conditional
27.
Which of the following is an example for Binary Operator
a)
Arithmentic
b)
Increment
c)
Logical Not
d)
Decrement
28.
Which of the following is an example for Ternary Operator
a)
Increment
b)
Relational
c)
Logical
d)
Conditional
29.
Decrement Operator -- decreases value of variable by what number?
a)
2
b)
1
c)
3
d)
4
30.
When operators are having same priority, they are evaluated from ______ in gthe order they appear in the expression
a)
left to right
b)
right to left
c)
any of the above
d)
None of these
31.
If j and k are int type variables, what will be the result of the expression j%k when j=10 and k=3
a)
1
b)
10
c)
3
32.
What will be the result of the expression -14%-3
a)
2
b)
-2
c)
4
d)
-4
33.
What is the value of X for the expression X=9-12/3+3*2-1
a)
11
b)
10
c)
7
d)
8
34.
if a=20 and b=15 then the statement x=(a>b)?a:b; will assign value of x
a)
5
b)
15
c)
20
d)
35
35.
If a and b are integers, then for a=14 and b=4 what will be the value of expression a/b
a)
3
b)
2
c)
4
d)
1
36.
Which of the following is not a decision making statements?
a)
if
b)
if-else
c)
switch
d)
do-while
37.
Which of the following is not a valid jump statements in Java?
a)
break
b)
goto
c)
continue
d)
return
38.
Which of the following is not a valid flow control statement?
a)
exit()
b)
break
c)
continue
d)
return
39.
Which of the following is not an OOPS concept?
a)
Encapsulation
b)
Polymorphism
c)
Abstraction
d)
Exception
40.
Which feature of OOPS described the reusability of code?
a)
Encapsulation
b)
Polymorphism
c)
Abstraction
d)
Inheritance
41.
Which feature of OOPS derives the class from another class?
a)
Encapsulation
b)
Polymorphism
c)
Abstraction
d)
Inheritance
42.
When is the object created with a new keyword?
a)
At run time
b)
At compile time
c)
Depends on the code
d)
None of these
43.
In OOPs private,public, protected are
a)
interfaces
b)
classes
c)
method
d)
Access specifiers
44.
Exposing only necessary information to clients is known as
a)
Abstraction
b)
Encapsulation
c)
Data Hiding
d)
Inheritance
45.
Identify the incorrect constructor type.
a)
friend constructor
b)
default constructor
c)
parametrised constructor
d)
None of these
46.
Constructor can return a value
a)
always
b)
sometimes
c)
atleast once
d)
never
47.
To create an object which among the keyword is used?
a)
extends
b)
public
c)
new
d)
static
48.
Which of these keywords can be used to prevent inheritance of a class?
a)
abstract
b)
extends
c)
super
d)
final
49.
Runtime polymorphism feature in Java is
a)
method overriding
b)
method overlaoding
c)
constructor overloading
d)
operator overloading
50.
Which keyword is used to inherit a class in Java?
a)
inherit
b)
extends
c)
extend
d)
implements
51.
For Cat and animal class , which one is correct statement?
a)
class Cat extends Animal
b)
Class Animal extends Cat
c)
Both are correct
d)
None of these
52.
IS-A relationship in Java is related to
a)
Encapsulation
b)
Composition
c)
Abstraction
d)
Inheritance
53.
If you want to write multiple functions in a class with same name, then that Java feature is
a)
Function overriding
b)
Encapsulation
c)
Function overloading
d)
None of these
54.
Which does not have a body?
a)
class
b)
abstract method
c)
interface
d)
None of these
55.
We cannot create an instance of _______
a)
nested class
b)
parent class
c)
abstract class
d)
anonymous class
56.
Types of polymorphism in java are
a)
compile time
b)
run time
c)
both A and B
d)
None of these
57.
Which of these keyword is used to define interfaces in Java?
a)
interface
b)
INTF
c)
INTERFACE
d)
None of these
58.
Which of these can be used to fully abstract a class from its implementation?
a)
Objects
b)
Packages
c)
Interfaces
d)
None of these
59.
Which of these keyword is used by a class to use an interface defined previously?
a)
import
b)
extends
c)
implements
d)
IMPLEMENTS
60.
An interface in Java is like a 100%
a)
abstract class
b)
public class
c)
inner class
d)
anonymous class
61.
All interface variables are _____ by default in Java
a)
public
b)
final
c)
public & final
d)
None of these
62.
All interface methods are _____ by default in Java
a)
public
b)
abstract method
c)
public & abstract
d)
None of these
63.
Which of these keywords is used to define a package in Java?
a)
pkg
b)
Pkg
c)
Package
d)
package
64.
Which of these access specifiers can be used for a class so that its members can be acceessed by a different class in the different package?
a)
public
b)
protected
c)
private
d)
None of these
65.
Which of the following is the correct way of importing an entire package?
a)
import pkg.
b)
import Pkg.
c)
import pkg.*;
d)
import *;
66.
Which of the following package stores all the standard java classes?
a)
lang
b)
java
c)
util
d)
io
67.
What is the maximum number of Java class files that can be kept inside a single java package?
a)
8
b)
64
c)
128
d)
Unlimited
68.
Which of these access specifiers can be used for a class so that its members can be accessed by a different class in the same package?
a)
public
b)
protected
c)
Both A and B
d)
none of these
69.
Package is a mechanism to encapsulate a _________
a)
classes
b)
sub packages
c)
interfaces
d)
all of the above
70.
Packages that are inside another package are the
a)
packages
b)
nested packages
c)
util packages
d)
subpackages
71.
An ____ statement can be used to access the classes and interface of a different package from the current package.
a)
instanceOf
b)
import
c)
extends
d)
implements
72.
Which of the following package is used to includes utility classes like Calendar, Collection, Date?
a)
java.lang
b)
java.net
c)
java.awt
d)
java.util
73.
The class at the top of exception class hierarchy is ________________
a)
ArithmeticException
b)
Throwable
c)
Object
d)
Exception
74.
When does Exceptions in Java arises in code sequence?
a)
Run time
b)
Compilation Time
c)
Can oocur any time
d)
None of these
75.
Exception is a ________
a)
class
b)
interface
c)
abstract class
d)
None of these
76.
In which of the following package Exception class exist?
a)
java.util
b)
java.lang
c)
java.io
d)
java.file
77.
Which of these keywords is not a part of exception handling?
a)
try
b)
catch
c)
thrown
d)
finally
78.
Which of these classes is the highest in the hierarchy in Java
a)
java.lang.Exception
b)
java.lang.Object
c)
java.lang.Throwable
d)
java.lang.Error
79.
Exception generated in try block is caught in __________block
a)
catch
b)
throw
c)
throws
d)
finally
80.
Which of these keywords must be used to monitor for exceptions?
a)
try
b)
finally
c)
throws
d)
catch
81.
Which keyword is used to explicitly throw an exception?
a)
try
b)
finally
c)
throw
d)
catch
82.
Which of the following blocks execute compulsorily whether exception is caught or not?
a)
finally
b)
catch
c)
throws
d)
throw
83.
Which Exception is thrown when divide by zero statement executes?
a)
NumberFormatException
b)
ArithmeticException
c)
NullPointerException
d)
None of theses
84.
Which of these keywords is used to manually throw an exception?
a)
try
b)
finally
c)
catch
d)
throw
85.
Which of the following keyword is used to explicitly raise an Exception?
a)
raise
b)
catch
c)
throw
d)
throws
86.
Which keyword is used to specify the exception thrown by method?
a)
catch
b)
throws
c)
finally
d)
throw
87.
Which exception is thrown when an array element is accessed beyond the array size?
a)
ArrayElementOutOFBounds
b)
ArrayIndexOutOfBoundsException
c)
Arithmetic Exceptions
d)
None of these
88.
Which of these are types of multitasking?
a)
Process based
b)
Thread based
c)
Process and Thread based
d)
None of the mentioned
89.
Thread priority in Java is?
a)
Integer
b)
Float
c)
Double
d)
Long
90.
Which of the following require less resource?
a)
Process
b)
Thread
c)
Process and Thread
d)
None Of these
91.
In java multi-threading, a thread can be created by
a)
Extending Thread class
b)
Implementing Runnable interface
c)
Using both
d)
None of these
92.
Which method is used to get current running thread object?
a)
runningThread()
b)
currentThread()
c)
runnableThread()
d)
none of these
93.
Which method is called internally by Thread start() method?
a)
execute()
b)
run()
c)
launch()
d)
main()
94.
The life cycle of a thread in java is controlled by
a)
JDK
b)
JRE
c)
JVM
d)
None of these
95.
What is maximum thread priority in Java
a)
10
b)
12
c)
5
d)
8
96.
Which of theses methods of Thread class is used to find out the priority of the given Thread()?
a)
get()
b)
ThreadPriority()
c)
getPriority()
d)
None of these
97.
Which method must be implemented by a Java thread?
a)
execute()
b)
run()
c)
launch()
d)
main()
98.
Which of the following method wakes up all threads?
a)
notify()
b)
notifyAll()
c)
wakeAll()
d)
start()
99.
Execution of a java thread begins on which method call?
a)
execute()
b)
run()
c)
launch()
d)
start()
100.
Which method is used to wait for child threads to finish in Java?
a)
join()
b)
wait()
c)
sleep()
d)
isAlive()
101.
Which of the method will contain the body of the thread in Java?
a)
execute()
b)
run()
c)
launch()
d)
start()
102.
Which thread will be executed first if two threads have same priority
a)
They will fall in starvation and none will be executed.
b)
Both will be executed simultaneously
c)
It depends upon operating system
d)
They will be executed on first come first serve basis
103.
How many ways a thread can be created in Java multithreading?
a)
1
b)
2
c)
3
d)
4
104.
Which method is used to make main thread to wait for all child threads
a)
join()
b)
sleep()
c)
wait()
d)
stop()
105.
Default value of a java thread is
a)
0
b)
1
c)
5
d)
10
106.
Which method is used to check if a thread is running?
a)
isAlive()
b)
run()
c)
keepAlive()
d)
alive()
107.
Min and Max priority of a thread in Java multithreading are
a)
1,10
b)
5,10
c)
1,5
d)
10,10
108.
Daemon thread runs in
a)
Background
b)
Foreground
c)
both
d)
none of these
109.
Thread synchronization in a process will be required when
a)
All threads sharing the same address space
b)
All threads sharing the same global variables
c)
All threads sharing the same files
d)
All of the above
110.
Which of these packages contain classes and interfaces used for input & output operations of a program?
a)
java.util
b)
java.lang
c)
java.io
d)
all of the above
111.
Which of these class is not a member class of java.io package?
a)
String
b)
StringReader
c)
Writer
d)
File
112.
Java I/O is used to process the?
a)
Input
b)
Output
c)
Both
d)
None of these
113.
Which of these is method for testing whether the specified element is a file or a directory?
a)
IsFile()
b)
isFile()
c)
Isfile()
d)
isfile()
114.
In java, how many streams are created for us automatically?
a)
2
b)
3
c)
4
d)
5
115.
Which of these is a type of stream in Java?
a)
Integer Stream
b)
Byte Stream
c)
Short Stream
d)
Long Stream
116.
Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?
a)
transient
b)
global
c)
volatile
d)
no modifier
117.
Transient keyword in java is used in
a)
serialization
b)
synchronization
c)
inheritance
d)
polymorphism
118.
The instanceof operator can be used to determine if an object is:
a)
An instance of a class that implements a given interface
b)
An instance of a class
c)
An instance of a subclass of a class
d)
All of these
119.
Which of these operators can be used to get run time information about an object?
a)
getInfo()
b)
info()
c)
instanceOf()
d)
getIn()
120.
instanceOf is an ____________
a)
datatype
b)
function
c)
operator
d)
None of these
121.
Which of these is Wrapper class for int type?
a)
Long
b)
Byte
c)
Integer
d)
Short
122.
Which of these class is a super class of wrappers Long, Character & Integer?
a)
Long
b)
Digits
c)
Floats
d)
Number
123.
The automatic conversion of a primitive data type into its wrapper class is called as ______
a)
autoboxing
b)
autounboxing
c)
casting
d)
none of these
124.
Automatic conversion of a wrapper class into the corresponding primitive datatype is called as _____
a)
autoboxing
b)
autounboxing
c)
casting
d)
none of these
125.
Which of these is a wrapper class for type char?
a)
Float
b)
Character
c)
Integer
d)
Short
126.
Which of these class is used to create an object whose character sequence is mutable?
a)
String()
b)
StringBuffer()
c)
String() & StringBuffer()
d)
None of these
127.
Which of this method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
a)
concat()
b)
join()
c)
append()
d)
concatenate()
128.
Which of these method of class StringBuffer is used to find the length of current character sequence?
a)
length()
b)
Length()
c)
Capacity()
d)
capacity()
129.
Which of these class is used to create an object whose character sequence is mutable?
a)
String()
b)
StringBuffer()
c)
Both
d)
None of these
130.
What is the string contained in s after following lines of code? StringBuffer s new StringBuffer("Hello); s.deleteCharAt(0);
a)
Hell
b)
ello
c)
Hel
d)
llo
131.
Which of these method of class StringBuffer is used to extract a substring from a String object?
a)
substring()
b)
SubString()
c)
subString()
d)
None of these
132.
What will s2 contain after following lines of code? StringBuffer s1 = "one; StringBuffer s2 = s1.append("two)
a)
one
b)
two
c)
twoone
d)
onetwo
133.
Which of these method of Object class can generate duplicate copy of the object on which it is called?
a)
clone()
b)
copy()
c)
duplicate()
d)
none of these
134.
Which of these class contains only floating point functions?
a)
Math
b)
Process
c)
System
d)
Object
135.
What is the value of “d” in the following Java code snippet? double d = Math.round ( 2.5 + Math.random() );
a)
2
b)
3
c)
4
d)
2.5
136.
What decides thread priority?
a)
Process
b)
Process Scheduler
c)
Thread
d)
Thread Scheduler
137.
Which of these packages contain all the collection classes?
a)
java.lang
b)
java.net
c)
java.awt
d)
java.util
138.
Which of these classes is not part of Java’s collection framework?
a)
map
b)
array
c)
stack
d)
queue
139.
Which of these methods deletes all the elements from invoking collection?
a)
clear()
b)
reset()
c)
delete()
d)
refresh()
140.
What is Collection in Java?
a)
A group of objects
b)
A group of classes
c)
A group of interfaces
d)
None of these
141.
Which of these interface must contain a unique element?
a)
Set
b)
List
c)
Arrays
d)
Collection
142.
Which of these is Basic interface that all other interface inherits?
a)
Set
b)
List
c)
Arrays
d)
Collection
143.
Which of these methods sets every element of a List to a specified object?
a)
set()
b)
complete()
c)
add()
d)
fill()
144.
Which of these methods can randomize all elements in a list?
a)
rand()
b)
randomise()
c)
shuffle()
d)
all()
145.
Using Iterator(I) we can perform?
a)
read operation
b)
remove operation
c)
add or update
d)
both A & B
146.
Which of these methods can be used to move to next element in a collection?
a)
next()
b)
move()
c)
shuffle()
d)
hasNext()
147.
Using ListIterator(I) we can perform?
a)
read operation
b)
remove operation
c)
add or update
d)
All the above
148.
Which of these return type of hasNext() method of an iterator?
a)
Integer
b)
Boolean
c)
Double
d)
None of these
149.
Enumeration and Iterator is ____ but ListIterator is ____ ?
a)
Unidirectional, Bidirectional
b)
Bidirectional, Unidirectional
c)
Unidirectional, Unidirectional
d)
Bidirectional, Bidirectional
150.
Which of these is a method of ListIterator used to obtain index of previous element?
a)
previous()
b)
previousIndex()
c)
back()
d)
goBack()
151.
Which of these exception is thrown in cases when the file specified for writing is not found?
a)
FileException
b)
IOException
c)
FileNotFoundException
d)
None of these
152.
Which of these methods is used to write() into a file?
a)
put()
b)
putFile()
c)
write()
d)
writeFile()
153.
Which of these methods are used to read in from file?
a)
read()
b)
get()
c)
readFile()
d)
none of these
154.
Which of these exception is thrown by close() and read() methods?
a)
FileException
b)
IOException
c)
FileNotFoundException
d)
FileInputOutputException
155.
Which of these values is returned by read() method is end of file (EOF) is encountered?
a)
0
b)
1
c)
-1
d)
NULL
156.
Which of these is a process of writing the state of an object to a byte stream?
a)
Serialization
b)
Externalization
c)
File Filtering
d)
All of the mentioned
157.
Which of these process occur automatically by the java runtime system?
a)
Serialization
b)
Garbage collection
c)
File Filtering
d)
All of the mentioned
158.
Which of these is an interface for control over serialization and deserialization?
a)
Serialization
b)
Externalization
c)
File Filtering
d)
ObjectInput
159.
Which of these functions is called to display the output of an applet?
a)
display()
b)
print()
c)
paint()
d)
init()
160.
An applet is a Java class that extends the?
a)
java.Applet class
b)
java class
c)
Applet class
d)
java.applet.Applet class
161.
Applets are designed to be embedded within an __________.
a)
SQL
b)
HTML
c)
CSS
d)
Javascript
162.
Which method is automatically called after the browser calls the init method?
a)
start()
b)
stop()
c)
destroy()
d)
paint()
163.
Which method is only called when the browser shuts down normally?
a)
start()
b)
stop()
c)
destroy()
d)
paint()
164.
paint() is an abstract method defined in AWT.
a)
True
b)
FALSE
c)
Can be TRUE or FALSE
d)
cannot say
165.
Which of these methods can be used to output a string in an applet?
a)
display()
b)
print()
c)
drawString()
d)
run()
166.
Which of these methods is a part of Abstract Window Toolkit (AWT) ?
a)
display()
b)
paint()
c)
drawString()
d)
transient()
167.
To pass the parameters to the Applet which of the attribute of <applet> tag is used?
a)
param
b)
code
c)
width
d)
height
168.
To retrieve a parameter's value, we need to use the _______ method of Applet class.
a)
Parameter()
b)
getParameter()
c)
param()
d)
none of these
169.
___________ method is defined in Graphics class, it is used to output a string in an applet.
a)
display()
b)
print()
c)
init()
d)
drawString()
170.
What does AWT stands for?
a)
All Window Tools
b)
All Writing Tools
c)
Abstract Window Toolkit
d)
Abstract Writing Toolkit