wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Advance Java Unit-1 and 2

Total questions: 94

Worksheet time: 47mins

Name
Class
Date
1.

What is a thread in Java?

a)

A program

b)

A process

c)

Smallest unit of execution

d)

A class

2.

Every Java program starts with which thread?

a)

Child thread

b)

User thread

c)

Main thread

d)

Daemon thread

3.

Which method starts a new thread?

a)

run()

b)

init()

c)

start()

d)

execute()

4.

Which method contains code executed by a thread?

a)

start()

b)

run()

c)

main()

d)

stop()

5.

Calling run() directly will:

a)

Create new thread

b)

Stop JVM

c)

Act like normal method

d)

Cause error

6.

How many ways are there to create a thread in Java?

a)

1

b)

2

c)

3

d)

4

7.

Which interface is used to create a thread?

a)

Serializable

b)

Cloneable

c)

Runnable

d)

Callable

8.

Thread priority range is:

a)

0–5

b)

1–10

c)

1–5

d)

0–10

9.

Default thread priority is:

a)

1

b)

3

c)

5

d)

10

10.

Which method pauses thread execution?

a)

stop()

b)

wait()

c)

sleep()

d)

join()

11.

sleep() method throws:

a)

IOException

b)

RuntimeException

c)

InterruptedException

d)

NullPointerException

12.

Which method waits for another thread to finish?

a)

sleep()

b)

wait()

c)

join()

d)

stop()

13.

setDaemon(true) means:

a)

Thread becomes main

b)

Thread becomes background

c)

Thread stops

d)

JVM stops

14.

JVM exits when:

a)

Main thread ends

b)

Only daemon threads remain

c)

Any thread ends

d)

Garbage collector runs

15.

Which method checks thread status?

a)

isAlive()

b)

isRunning()

c)

isActive()

d)

status()

16.

Which keyword prevents data inconsistency?

a)

final

b)

static

c)

synchronized

d)

volatile

17.

Synchronization is used to:

a)

Increase speed

b)

Stop threads

c)

Control shared resource access

d)

Create threads

18.

wait() method:

a)

Stops thread permanently

b)

Releases lock and waits

c)

Sleeps thread

d)

Ends thread

19.

notify() method:

a)

Stops all threads

b)

Wakes all threads

c)

Wakes one waiting thread

d)

Pauses thread

20.

notifyAll() wakes:

a)

One thread

b)

Main thread

c)

All waiting threads

d)

Daemon thread

21.

Window is a:

a)

Container

b)

Layout

c)

Listener

d)

Event

22.

Window has title bar?

a)

Yes

b)

No

23.

Frame is subclass of:

a)

Panel

b)

Window

c)

Applet

d)

Dialog

24.

Frame supports menu bar?

a)

Yes

b)

No

25.

Which package contains Frame class?

a)

java.io

b)

java.util

c)

java.awt

d)

javax.swing

26.

setSize() method is used for:

a)

Visibility

b)

Color

c)

Window size

d)

Layout

27.

setVisible(true) makes frame:

a)

Close

b)

Hidden

c)

Appear

d)

Resize

28.

Which is top-level container?

a)

Button

b)

Label

c)

Frame

d)

TextField

29.

Graphics class is used to:

a)

Handle events

b)

Draw shapes

c)

Store data

30.

drawLine() draws:

a)

Circle

b)

Rectangle

c)

Line

d)

Text

31.

Which method draws text?

a)

drawText()

b)

print()

c)

drawString()

d)

write()

32.

Which class handles colors?

a)

Paint

b)

RGB

c)

Color

d)

Graphics

33.

Color.RED represents:

a)

Green

b)

Blue

c)

Red

d)

Black

34.

FontMetrics gives:

a)

Font style

b)

Font size only

c)

Font measurements

d)

Font color

35.

stringWidth() returns:

a)

Height

b)

Width of string

c)

Font size

d)

Color

36.

Label is used for:

a)

Input

b)

Display text

c)

Click

d)

Scroll

37.

Button generates:

a)

ItemEvent

b)

MouseEvent

c)

ActionEvent

d)

KeyEvent

38.

Checkbox allows:

a)

Single selection

b)

Multiple selection

c)

No selection

d)

Text input

39.

Scrollbar is used for:

a)

Text input

b)

Navigation

c)

Display

d)

Click

40.

TextField allows:

a)

Multi-line input

b)

Single-line input

c)

No input

d)

Image input

41.

TextArea supports:

a)

Single line

b)

Multiple lines

c)

Images

d)

Buttons

42.

TextArea belongs to:

a)

java.io

b)

java.sql

c)

java.awt

d)

java.net

43.

Checkbox default state can be:

a)

Only false

b)

Only true

c)

True or false

d)

Null

44.

Layout manager arranges:

a)

Threads

b)

Windows

c)

Components

d)

Events

45.

setLayout(null) means:

a)

Automatic layout

b)

Grid layout

c)

Manual positioning

d)

Flow layout

46.

Button is clickable component?

a)

Yes

b)

No

47.

Label is editable?

a)

Yes

b)

No

48.

Scrollbar can be:

a)

Vertical only

b)

Horizontal only

c)

Both

d)

None

49.

AWT stands for:

a)

Abstract Window Toolkit

b)

Advanced Window Tool

c)

Application Window Tool

d)

Automatic Window Toolkit

50.

AWT is:

a)

Platform independent

b)

Platform dependent

c)

Both

51.

Event handling in Button uses:

a)

KeyListener

b)

ActionListener

c)

MouseListener

d)

WindowListener

52.

TextField fires event on:

a)

Mouse click

b)

Scroll

c)

Enter key

d)

Resize

53.

Frame close button belongs to:

a)

Window

b)

Frame

c)

Panel

d)

Applet

54.

GUI components belong to:

a)

java.lang

b)

java.util

c)

java.awt

d)

java.io

55.

Which control is read-only?

a)

TextField

b)

TextArea

c)

Label

d)

Checkbox

56.

Java Applet runs inside:

a)

JVM only

b)

Command prompt

c)

Web browser

d)

Server

57.

Which method is called only once in applet life cycle?

a)

start()

b)

paint()

c)

init()

d)

destroy()

58.

Which method is used to draw graphics in applet?

a)

draw()

b)

display()

c)

paint()

d)

show()

59.

Applet does NOT have which method?

a)

init()

b)

start()

c)

main()

d)

destroy()

60.

Which method is called when applet becomes visible?

a)

init()

b)

start()

c)

paint()

d)

stop()

61.

Applet extends which class?

a)

Frame

b)

Panel

c)

Applet

d)

Window

62.

Applet uses which default layout?

a)

BorderLayout

b)

GridLayout

c)

FlowLayout

d)

Null

63.

Applet security restriction is:

a)

Can access local file

b)

Can run OS commands

c)

Cannot access local file

d)

Can shut down system

64.

Which tag was originally used for applet in HTML?

a)

<java>

b)

<applet>

c)

<object>

d)

<script>

65.

Which method is called when browser closes applet?

a)

stop()

b)

destroy()

c)

init()

d)

paint()

66.

Applet programming is:

a)

Server side

b)

Client side

c)

Database side

d)

Compiler side

67.

Which method stops applet temporarily?

a)

destroy()

b)

stop()

c)

init()

68.

Applet runs without main() because:

a)

Browser controls execution

b)

JVM blocks it

c)

Compiler ignores it

d)

OS controls it

69.

Applet is:

a)

Console based

b)

GUI based

c)

Database based

d)

Text based

70.

Swing classes are present in which package?

a)

java.awt

b)

java.io

c)

javax.swing

d)

java.util

71.

Swing components are:

a)

Heavyweight

b)

Lightweight

c)

OS dependent

d)

Hardware dependent

72.

Which is a Swing top-level container?

a)

JPanel

b)

JButton

c)

JFrame

d)

JLabel

73.

JButton generates which event?

a)

ItemEvent

b)

ActionEvent

c)

WindowEvent

d)

MouseEvent

74.

Which component is used to display text in Swing?

a)

JButton

b)

JTextField

c)

JLabel

d)

JTextArea

75.

JTextField allows:

a)

Multiple line input

b)

Image input

c)

Single line text

d)

Table data

76.

Which component is used for password input?

a)

JTextArea

b)

JTextField

c)

JPasswordField

d)

JLabel

77.

JCheckBox allows:

a)

Only one selection

b)

Multiple selections

c)

No selection

d)

Text entry

78.

JRadioButton is used with:

a)

JPanel

b)

JFrame

79.

JMenuBar is added to:

a)

JPanel

b)

JFrame

c)

JButton

d)

JTextArea

80.

JOptionPane is used for:

a)

Database

b)

File handling

c)

Dialog boxes

d)

Layout

81.

JTable is used to display:

a)

Images

b)

Buttons

c)

Tabular data

d)

Text only

82.

Swing follows which architecture?

a)

Client-server

b)

MVC

c)

Monolithic

d)

Procedural

83.

Swing is built on top of:

a)

JavaFX

b)

AWT

c)

Applet

d)

Servlet

84.

Swing application starts execution from:

a)

init()

b)

start()

c)

main()

d)

paint()

85.

Which component supports multiple lines of text?

a)

JTextField

b)

JLabel

c)

JTextArea

d)

JButton

86.

Which Swing component displays list of items?

a)

JTable

b)

JList

c)

JComboBox

d)

JMenu

87.

JComboBox is also called:

a)

Text box

b)

Drop-down list

c)

Table

d)

Dialog

88.

Swing uses which event model?

a)

Polling

b)

Delegation

c)

Interrupt

d)

Thread model

89.

Swing components start with letter:

a)

A

b)

S

c)

J

90.

Which is NOT a Swing component?

a)

JButton

b)

JCheckBox

c)

Button

d)

JTextField

91.

JLabel is:

a)

Editable

b)

Read-only

c)

Clickable

d)

Scrollable

92.

Swing applications are:

a)

Browser dependent

b)

Platform dependent

c)

Platform independent

d)

OS dependent

93.

JPanel is used for:

a)

Drawing only

b)

Grouping components

c)

Closing window

d)

Event handling

94.

Which layout is default for JPanel?

a)

BorderLayout

b)

GridLayout

c)

FlowLayout

d)

Null