Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Unit Iii

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

UNIT III - STRINGS AND EXCEPTION HANDLING

String Operations - Exceptions - Exception hierarchy - Throwing and catching exceptions - built-in
exceptions, creating own exceptions – Packages-Input / Output Basics – Streams – Byte streams and
Character streams – Reading and Writing Console – Reading and Writing Files
PART – A
Q. No. Questions BT Competence
Level
1. What is meant by Strings in Java? BTL1 Remembering
2. Define Exception. What is its use? BTL1 Remembering
3. List the different categories of Java packages. BTL1 Remembering
4. State the general form of an exception handling block. BTL1 Remembering
5. List the ways to search the strings. BTL1 Remembering
6. What is meant by packages? BTL1 Remembering
7. What are the constructors used for creating a string with byte BTL2 Understanding
array?
8. What are the various segments of an exception handling BTL2 Understanding
mechanism?
9. Identify the advantages of using exception handling mechanism. BTL2 Understanding
10. Identify the steps involved in creating packages. BTL2 Understanding
11. How can you directly access all classes in the packages? BTL3 Applying
12. How can you access the class if it is declared without any access BTL3 Applying
modifiers?
13. Why Java generates unreachable code error during multiple BTL3 Applying
catch statements?
14. What value is assigned to string type when it is automatically BTL4 Analyzing
initialized and specifies some operations that are performed
using string?
15. How to check the starting and ending point of a string? BTL4 Analyzing
16. What happens if an exception is not provided by the user? BTL4 Analyzing
17. Can you tell how to create a string with an array of characters? BTL5 Evaluating
18. Can an exception be rethrown? BTL5 Evaluating
19. Create a string object similar to another string. BTL6 Creating
20. Design a program to concatenate two strings. BTL6 Creating
21. Define Stream. BTL1 Remembering
22. What is meant by an input and output stream? BTL1 Remembering
23. List the types of Streams in Java and the methods defined in File BTL1 Remembering
class.
24. Define Thread and Multithreading. BTL1 Remembering
25. List the types of Multitasking. BTL1 Remembering
26. Tabulate the various states of a thread. BTL1 Remembering
27. Illustrate the use of write() method in PrintStream class. BTL2 Understanding
28. Summarize the Stream Tokenizer and RandomAccessFile. BTL2 Understanding
29. What are the rules for performing context switch? BTL2 Understanding
30. Identify the ways in which the threads may be created. BTL2 Understanding
31. How to read a string from the keyboard? BTL3 Applying
32. Which object controls the main thread? BTL3 Applying
33. Which thread is executed when Java program startsup? BTL3 Applying
34. What is the difference between the Reader/Writer class and the BTL4 Analyzing
InputStream / OutputStream class?
35. Which value will be returned by readLine() method when it BTL4 Analyzing
reached the End of File?
36. Differentiate the use and constructors available in BTL4 Analyzing
FileInputStream and FileOutputStream class.
37. Interpret what is an Exception. What is its use? BTL 2 Understand
38. Predict what function does terminate and unexpected handlers BTL 2 Understand
call.
39. What is re-throwing an expression? BTL 1 Remember
40. Define uncaught exception. BTL 1 Remember
41. Summarize the task performed by exception handling. BTL 2 Understand
42. Differentiate exception and error BTL 2 Understand
43. Classify the exception types with example BTL 4 Analyze
44. Draw the exception hierarchy. BTL 5 Evaluate
45. What are the two methods available in stack trace elements? BTL 1 Remember
46. Formulate the advantages of using exception handling. BTL 6 Create
47. What are three types of I/O streams? BTL 1 Remember
48. Show what is the purpose of the finally clause of a try-catch- BTL 3 Apply
finally statement?
49. Explain how to create custom exception. BTL 4 Analyze
50. List the any five byte stream class. BTL 1 Remember
51. Illustrate any four character stream class. BTL 3 Apply
52. Point out the syntax of buffered reader to connect to the BTL 4 Analyze
keyboard
53. What are streams? What are their advantages? BTL 1 Remember
54. Write a Java program to demonstrate the use of readline method. BTL 3 Apply
55. Develop a Java application using a printwriter class to handle BTL 6 Create
console output.
PART – B
1 Define exception. Why it is needed? Explain the different types BTL1 Remembering
of exceptions and the exception hierarchy with appropriate
examples using Java. (13)
2 Define package. How it is created and implemented in Java? BTL1 Remembering
(13)
3 List the benefits of using packages? Write down the steps in BTL1 Remembering
creating a package and using it in a Java program with an
example. (13)
4 Define String? How Strings are handled in Java? Explain with BTL1 Remembering
code. (13)
5 What is package? How to add a class into a package? (13) BTL2 Understanding
6 Discuss package concept to perform arithmetic operations. BTL2 Understanding
Explain how to use it? (13)
7 Discuss in detail about exception handling constructs and write a BTL2 Understanding
program to illustrate Divide by zero exception. (13)
8 Explain the following in Strings with example program: BTL3 Applying
i) Concatenation. (7)
ii) Substrings. (6)
9 How exceptions are handled in Java? Explain the important BTL3 Applying
methods used to handle exception. (13)
10 Explain the following in detail with example program BTL3 Applying
i. Checked Exception. (7)
ii. Unchecked exception. (6)
11 How do you compare two strings by ignoring the case? Give an BTL4 Analyzing
example Java program. (13)
12 Assess in detail about the reusable classes in Packages. (13) BTL4 Analyzing
13 Evaluate a try block that is likely to generate three types of BTL5 Evaluating
exception and then incorporate necessary catch blocks and
handle them appropriately. (13)
14 Draw an exception hierarchy in Java and explain with examples BTL6 Creating
throwing and catching exceptions and common exceptions. (13)
15 List the two ways of implementing threads with example BTL1 Remembering
program. (13)
16 Label the different states of a thread and explain it. (13) BTL1 Remembering
17 What are input and output streams? Explain them with BTL1 Remembering
illustrations. (13)
18 Describe the most commonly used classes for handling I/O BTL1 Remembering
related exceptions. (13)
19 What is a thread? Describe the complete lifecycle of thread. . BTL2 Understanding
(13)
20 Discuss briefly about the features BTL2 Understanding
i. Byte streams input/output. (7)
ii. Character streams input/output. (6)
1 Discuss in detail about exception handling constructs and write a (13) BTL 2
program to illustrate Divide by zero exception.
2 Describe the following concepts with example (7) BTL 1
i. Try-catch-throw paradigm. (6)
ii.Exception specification.
3 Describe about the syntax of catch and re-throw an (13) BTL 1
exception with an example
4 Point out the importance of exception hierarchy. (7) BTL 4
Explain on stack trace elements give example (6)
5 Tabulate any five classes to support exception handling in Java (13) BTL 1
with an example for each.
6 i. Summarize what is finally class. How to catch exception? (7) BTL 2
Write an example. (6)
ii. Give short notes on Java built in exceptions
7 Analyse the following in detail with example program (7) BTL 4
i.Checked Exception (6)
ii.Unchecked exception
8 i.Classify the errors and exception in Java. (7) BTL 3
ii.Illustrate about multiple catching exceptions with example. (6)
9 Summarize the following with example program (5) BTL5
i.Arithmetic exception (4)
ii.Arrayoutofbound exception (4)
ii.Stringindexoutofbound exception
10 i. Develop a program to read and count the characters from files. (7) BTL 6
ii.Develop a Java program to transfer the content of one file to (6)
another file.
11 Discuss briefly about the features (7) BTL 2
i. Byte streams input/output (6)
ii. Character streams input/output
12 Explain the following with example (7) BTL 4
i. Reading console input (6)
ii. Writing console output.
13 i.Identify a Java program to read characters from the console. (7) BTL 1
ii.Identify a Java program to read strings from the console. (6)
14 Illustrate in brief about (7) BTL 3
i. Reading from a file. (6)
ii. Writing in a file.

PART – C
1 i. Differentiate string buffer and strings. (8) BTL3 Applying
ii. Write a Java program to find the given string is palindrome or
not. (7)
2 i) Write a java program to raise an exception if the user prompts BTL4 Analyzing
with a value in the range from 10 to 30 also instruct the user
regarding the exception with a message “The value is not in the
allowed interval”. (8)
ii) Write a Java program to demonstrate
stringIndexOutOfBoundsException (7)
3 There are three statements in a try block – statement1, BTL5 Evaluating
statement2 and statement3. After that there is a catch block to
catch the exceptions occurred in the try block. Assume that
exception has occurred in statement2. Does statement3 get
executed or not? (15)
4 Does it matter in what order catch statements for BTL5 Evaluating
FileNotFoundException and IOException are written? (15)
5 Create a simple Java program to illustrate the concept of BTL6 Creating
packages and its types in detail.(15)
6 i) Write a Java program that prints the maximum of the sequence BTL4 Analyzing
of non negative integer values that are stored on the file data.txt.
We first concentrate on the problem with considering
exceptions.(8)
ii) Program to read from a file using BufferedReader class the
input file contains your name and register number (7)
7 i) Write a Java program to demonstrate FileNotFoundException BTL4 Analyzing
(5)
ii) Write a java program to illustrates how to create own
exception class MyException.(10)
a) Details of account numbers, customer names, and
balance amounts are taken in the form of three
arrays.
b) In main() method, the details are displayed using a
for-loop. At this time, check is done if in any account
the balance amount is less than the minimum balance
amount to be ept in the account.
If it is so, then MyException is raised and a message is displayed
“Balance amount is less”.
8 i) Write a java program to handle two exception Arithmetic BTL4 Analyzing
exception and array index out bound exception using nested try
block statements. outer try block raises array index out bound
exception and inner try block has Arithmetic exception. also
display the output . whether arithmetic exception is raised or
not and why?(10)
ii) write a java program to print your register number, emailId to a
text File using FileWriter class(5)
9 Develop a Java program to implement user defined exception BTL6 Create
handling.
10 i.Custom exception has been created in the code given below. BTL 5 Evaluate
Correct and evaluate the code
Class myexception extends Exception
{
Myexception(string s)
{
super(s)
}
}
Class excep
{
Public static void main(String args[])
{‘ if(args[0]== “Hello”)
System.out.println(“String is right”);
else
try
{
Throw new myexception(“Invalid string”);
}
Catch(myexception ex)
{
System.out.println(ex.gemessage());
}
}
}
ii.The program calculates sum of two numbers inputted as
command-line arguments.When will it give an exception?
Class execp
{
Public static void main( String []args)
{
try{
int n= Integer.parseInt(arg[0]);
int n1=Integer.parseInt(arg[1]);
int n2=n+n1;
System.out.println(“Sum is:” +n2);
}
Catch(NumberFormatException ex)
{
System.out.println(ex);
}
}}
11 Develop the Java program to concatenate the two files and BTL6 Create
produce the output in the third file (15)
12 Deduce a Java program that reads a file name from the user, BTL 5 Evaluate
displays information about whether the file exists, whether the
file is readable, or writable, the type of file and the length of the
file in bytes.

You might also like