0% found this document useful (0 votes)
7 views

JAVA Chapter 4

The document discusses various topics related to exceptions and threads in Java including defining exceptions, serialization, thread life cycle, thread priority, exception handling clauses like try, catch, throw and finally, thread methods like wait(), sleep(), resume() and notify(), types of errors, when exceptions occur, synchronization, and programs to demonstrate exception handling and using multiple threads.

Uploaded by

khanarman171717
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

JAVA Chapter 4

The document discusses various topics related to exceptions and threads in Java including defining exceptions, serialization, thread life cycle, thread priority, exception handling clauses like try, catch, throw and finally, thread methods like wait(), sleep(), resume() and notify(), types of errors, when exceptions occur, synchronization, and programs to demonstrate exception handling and using multiple threads.

Uploaded by

khanarman171717
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1 Define exception. How it is handled?

2 Explain serialization with suitable example for writing an object into file.
3 Explain thread life cycle with neat diagram. OR Describe life cycle of thread. OR What is thread
? Draw thread life cycle diagram in Java.
4 Explain thread priority and method to get and set priority values. OR What is thread priority ?
Write default priority values and methods to change them. OR Explain following terms :
(i) Thread Priority
(ii) Types of Exception OR What is thread priority ? How thread priority are set and changed
? Explain with example. OR Explain thread priority and method to get and set priority values.

5 Explain following clause w.r.t. exception handling :


(i) try
(ii) catch
(iii) throw
(iv) finally OR Define throws & finally statements with its syntax and example. OR What is
the use of try catch and finally statement give example. OR Describe use of ‘throws’ with
suitable example.
6 With proper syntax and example explain following thread methods :
(1) wait( )
(2) sleep( )
(3) resume( )
(4) notify( )
7 State & explain types of errors in Java. OR What are different types of error ? What is use of
throw, throws and finally statement ?
8 What is exception ? Why the exception occurred in program ? Explain with suitable example.
OR What is an exception ? How it is handled ? Give suitable example. OR What is exception ?
How it is handled ? Explain with suitable example. OR Define an exception. How it is handled ?
9 What is synchronization ? When do we use it ? Explain synchronization of two threads.
10 Define an exception called ‘No match Exception’ that is thrown when a string is not equal to
“MSBTE”. Write program.
11 What is exception ? WAP to accept a password from the user and throw “Authentication
Failure” exception if the password is incorrect. OR Write a program to accept password from
user and throw ‘Authentication failure’ exception if password is incorrect.
12 Explain following methods related to threads : 1) suspend ( ) 2) resume ( ) 3) yield ( ) 4) wait ( )
13 Write a program to create two threads ; one to print numbers in original order and other to
reverse order from 1 to 50.
14 Write a program to define two thread one to print from 1 to 100 and other to print from 100
to 1. First thread transfer control to second thread after delay of 500 ms.
15 Write a program to create two threads, one to print numbers in original order and other in
reverse order from 1 to 10.
16 Write a program to input name and balance of customer and thread an user defined exception
if balance less than 1500.
17 Write a program to create two thread one to print odd number only and other to print even
numbers.
18 Write a program to create two threads, so one thread will print even numbers between 1 to 10
whereas other will print odd numbers between 11 to 20.
19 Write a program to input name and age of person and throws user defined exception, if
entered age is negative .

You might also like