wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java

Total questions: 65

Worksheet time: 22mins

Name
Class
Date
1.
Which of these keywords is used to define packages in Java?
a)
pkg
b)
Pkg
c)
package
d)
Package
2.
A Package is a collection of
a)
classes
b)
interfaces
c)
editing tools
d)
classes and interfaces
3.
in java multi-threading, a thread can be created by
a)
Extending thread Class
b)
Implementing Runnable interface
c)
Using Both
d)
None
4.
Which of these keywords is not a part of exception handling?
a)
try
b)
finally
c)
thrown
d)
catch
5.
Which method is called internally by Thread start() method?
a)
execute()
b)
run()
c)
launch()
d)
main()
6.
Which of these keywords must be used to handle the exception thrown by try block in some rational manner?
a)
try
b)
finally
c)
thrown
d)
catch
7.
Which of this access specifies 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)
No Modifier
d)
All of the mentioned
8.
Math class is in ________ package.
a)
java.io
b)
java.lang
c)
java.util
d)
java.applet
9.
Which of the following keyword is used by calling function to handle exception thrown by called function?
a)
throws
b)
throw
c)
try
d)
catch
10.
Thread priority in Java is?
a)
Integer
b)
Float
c)
double
d)
long
11.
Which method must be implemented by a Java thread?
a)
run()
b)
execute()
c)
start()
d)
None
12.
At runtime, error is recoverable.
a)
true
b)
false
13.
Which of the following is correct way of importing an entire package ‘pkg’?
a)
import pkg.
b)
Import pkg.
c)
import pkg.*
d)
Import pkg.*
14.
Exception is a
a)
Class
b)
Interface
c)
Abstract class
d)
Other
15.
Which of these class is highest in hierarchy in java
a)
java.lang.Exception
b)
java.lang.Error
c)
java.lang.Throwable
d)
java.lang.Object
16.
What is sometimes also called a lightweight process?
a)
Thread
b)
Process
c)
JVM
17.
Which of these is not a Thread state?
a)
New
b)
Runnable
c)
sleep
d)
terminated
18.
Exception and Error are direct subclasses of?
a)
BaseException
b)
Throwable
c)
Object
d)
RuntimeException
19.
What type of Exceptions can be ignored at compile time?
a)
Runtime
b)
Checked
c)
Both
d)
None
20.
Which method can make Thread to go from running to waiting state
a)
wait()
b)
resume()
c)
notify()
d)
alive()
21.
Which is the container that doesn't contain title bar and MenuBars but it can have other components like button, textfield etc?
a)
Window
b)
Frame
c)
Panel
d)
Container
22.
Give the abbreviation of AWT?
a)
Applet Window Toolkit
b)
Abstract Window Toolkit
c)
Absolute Window Toolkit
d)
None of the above
23.
Which is the container that contain title bar and can have MenuBars. It can have other components like button, textfield etc.?
a)
Panel
b)
Frame
c)
Window
d)
Container
24.
AWT is used for GUI programming in java?
a)
true
b)
false
25.
Which class provides many methods for graphics programming?
a)
java.awt
b)
java.Graphics
c)
java.awt.Graphics
d)
None of the above
26.
Which object can be constructed to show any number of choices in the visible window?
a)
Labels
b)
Choice
c)
List
d)
Checkbox
27.
In which places can put the event handling code
a)
Same class
b)
Other class
c)
Annonymous class
d)
All mentioned above
28.
Which is used to store data and partial results, as well as to perform dynamic linking, return values for methods, and dispatch exceptions?
a)
Window
b)
Panel
c)
Frame
d)
Container
29.
How many types of controls does AWT supports these controls are subclasses of component?
a)
7
b)
6
c)
5
d)
8
30.
Which are passive controls that do not support any interaction with the user?
a)
Choice
b)
List
c)
Labels
d)
Checkbox
31.
By which method You can set or change the text in a Label?
a)
setText()
b)
getText()
c)
Both A & B
d)
None of the above
32.

When an applet is terminated which of the following sequence of methods calls take place?

a)

stop(),paint(),destroy()

b)

destroy(),stop(),paint()

c)

destroy(),stop()

d)

stop(),destroy()

33.

Types of exceptions in Java programming are

a)

Checked exception

b)

unchecked exception

c)

Both A & B

d)

None

34.

Checked exception caught at

a)

compile time

b)

run time

c)

Both at compile and run time

d)

None

35.

Which is the super class of all java exceptions classes?

a)

Exception

b)

RuntimeException

c)

Throwable

d)

IOException

36.

un-checked(runtime) exception in java is/are

a)

ArrayIndexOutOfBoundsException

b)

ArithmeticException

c)

NullPointerException

d)

All

37.

Incorrect statement(s) about finally block in java exception

a)

Finally block always follow try catch block

b)

finally block always executes whether exception is handled or not.

c)

There can be multiple finally blocks followed by try catch block.

d)

All are correct

38.

True statement(s) about try catch block

a)

It is mandatory to have catch block with every try block

b)

There must be only one catch block followed by try block

c)

There can be multiple catch block followed by try block.

d)

All

39.

Which is not an exception in Java?

a)

IO Exception

b)

Logical Exception

c)

Array Index out of bound Exception

d)

Arithmetic Exception

40.

Which of these keywords is used to manually throw an exception?

a)

try

b)

finally

c)

throw

d)

catch

41.

Which of these methods are used to register a keyboard event listener?

a)

KeyListener()

b)

addKistener()

c)

addKeyListener()

d)

eventKeyboardListener()

42.

Which of these is a type of stream in Java?

a)

Integer stream

b)

Short stream

c)

Byte stream

d)

Long stream

43.

Which of these classes are used by Byte streams for input and output operation?

a)

InputStream

b)

InputOutputStream

c)

Reader

d)

All of the mentioned

44.

Which of these classes are used by character streams for input and output operations?

a)

InputStream

b)

Writer

c)

ReadStream

d)

InputOutputStream

45.

Which of these class is used to read from byte array?

a)

InputStream.

b)

BufferedInputStream

c)

ArrayInputStream

d)

ByteArrayInputStream

46.

Which exception is thrown by read() method?

a)

IOException

b)

InterruptedException

c)

SystemException

d)

SystemInputException

47.

Which of these is used to read a string from the input stream?

a)

get()

b)

getLine()

c)

read()

d)

readLine()

48.

Which of these class is used to read characters and strings in Java from console?

a)

BufferedReader

b)

StringReader

c)

BufferedStreamReade

d)

InputStreamReader

49.

Which of these classes are used by Byte streams for input and output operation?

a)

InputStream

b)

InputOutputStream

c)

Reader

d)

All of the mentioned

50.

Which of these class is implemented by FilterInputStream class?

a)

InputStream

b)

BufferedInputStream

c)

FileInputStream

d)

BufferedFileInputStream

51.

Which of these methods can be used to writing console output?

a)

print()

b)

println()

c)

write()

d)

All of the mentioned

52.

Which of these class is used to create an object whose character sequence is mutable?

a)

String()

b)

StringBuffer()

c)

Both of the mentioned

d)

None of the mentioned

53.

Which of these method of class StringBuffer is used to reverse sequence of characters?

a)

reverse()

b)

reverseall()

c)

Reverse()

d)

reverseAll()

54.

Which of these classes are used by character streams output operations?

a)

InputStream

b)

Writer

c)

ReadStream

d)

InputOutputStream

55.

How many ways a thread can be created in Java multithreading?

a)

1

b)

2

c)

3

d)

4

56.

Which statements is/are correct

a)

On calling Thread start () method a new thread get created.

b)

Thread start () method call run () method internally

c)

Thread run () method can also be called directly to create thread.

d)

All correct

57.

Which method is used to make main thread to wait for all child threads

a)

Join ()

b)

Sleep ()

c)

Wait ()

d)

Stop ()

58.

Default value of a java thread is

a)

0

b)

1

c)

5

d)

10

59.

Which method is used to check if a thread is running?

a)

isAlive()

b)

run ()

c)

alive ()

d)

keepAlive()

60.

Min and Max priority of a thread in Java multithreading are

a)

1, 10

b)

0,10

c)

0,255

d)

1,256

61.

Daemon thread runs in

a)

Background

b)

Foreground

c)

Both

d)

none

62.

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

63.

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

64.

The life cycle of a thread in java is controlled by

a)

JRE

b)

JDK

c)

JVM

d)

None

65.

Which method is used to get current running thread object?

a)

runningThread()

b)

currentThread()

c)

runnableThread()

d)

None