Chapter library
Java Libraries and Exception Handling · Class XII · Part B
Open an answer to check your recall, or turn this topic into an MCQ quiz.
Fundamentals of Java Programming
Java Libraries and Exception Handling
Practice this chapter1 Explain “Scanner” with an example.
Scanner can parse input from sources such as the console.
Trace Java code in the order it executes. Keep track of the type and value of each variable, which condition is evaluated and how the result is returned or shown. Arrays.sort orders values in a supplied array. String.length reports the number of UTF-16 code units. Try block contains code whose exceptional outcomes can be handled.
Example. A student creates a small marks calculator. It takes two numbers, chooses an action based on the input and displays a result. The student tests normal numbers and invalid text separately to see which part of the program handles each case.
The important point is what “Scanner” does in a specific situation. To see the difference between this idea and the others in this chapter, compare what each one affects and which result would show that it had been used correctly. Use one concrete detail, such as a number, file name, message or action, to show exactly what you mean and how someone could check it.
174 words
2 Explain “Arrays.sort” with an example.
Arrays.sort orders values in a supplied array.
Trace Java code in the order it executes. Keep track of the type and value of each variable, which condition is evaluated and how the result is returned or shown. String.length reports the number of UTF-16 code units. Try block contains code whose exceptional outcomes can be handled. Catch block handles a matching exception.
Example. A student creates a small marks calculator. It takes two numbers, chooses an action based on the input and displays a result. The student tests normal numbers and invalid text separately to see which part of the program handles each case.
The important point is what “Arrays.sort” does in a specific situation. To see the difference between this idea and the others in this chapter, compare what each one affects and which result would show that it had been used correctly. Use one concrete detail, such as a number, file name, message or action, to show exactly what you mean and how someone could check it.
171 words
3 Explain “String.length” with an example.
String.length reports the number of UTF-16 code units.
Trace Java code in the order it executes. Keep track of the type and value of each variable, which condition is evaluated and how the result is returned or shown. Try block contains code whose exceptional outcomes can be handled. Catch block handles a matching exception. Finally block normally runs as control leaves a try statement.
Example. A student creates a small marks calculator. It takes two numbers, chooses an action based on the input and displays a result. The student tests normal numbers and invalid text separately to see which part of the program handles each case.
The important point is what “String.length” does in a specific situation. To see the difference between this idea and the others in this chapter, compare what each one affects and which result would show that it had been used correctly. Use one concrete detail, such as a number, file name, message or action, to show exactly what you mean and how someone could check it.
173 words
4 Explain “Try block” with an example.
Try block contains code whose exceptional outcomes can be handled.
Trace Java code in the order it executes. Keep track of the type and value of each variable, which condition is evaluated and how the result is returned or shown. Catch block handles a matching exception. Finally block normally runs as control leaves a try statement. Scanner can parse input from sources such as the console.
Example. A student creates a small marks calculator. It takes two numbers, chooses an action based on the input and displays a result. The student tests normal numbers and invalid text separately to see which part of the program handles each case.
The important point is what “Try block” does in a specific situation. To see the difference between this idea and the others in this chapter, compare what each one affects and which result would show that it had been used correctly. Use one concrete detail, such as a number, file name, message or action, to show exactly what you mean and how someone could check it.
174 words
5 Explain “Catch block” with an example.
Catch block handles a matching exception.
Trace Java code in the order it executes. Keep track of the type and value of each variable, which condition is evaluated and how the result is returned or shown. Finally block normally runs as control leaves a try statement. Scanner can parse input from sources such as the console. Arrays.sort orders values in a supplied array.
Example. A student creates a small marks calculator. It takes two numbers, chooses an action based on the input and displays a result. The student tests normal numbers and invalid text separately to see which part of the program handles each case.
The important point is what “Catch block” does in a specific situation. To see the difference between this idea and the others in this chapter, compare what each one affects and which result would show that it had been used correctly. Use one concrete detail, such as a number, file name, message or action, to show exactly what you mean and how someone could check it.
172 words
6 Explain “Finally block” with an example.
Finally block normally runs as control leaves a try statement.
Trace Java code in the order it executes. Keep track of the type and value of each variable, which condition is evaluated and how the result is returned or shown. Scanner can parse input from sources such as the console. Arrays.sort orders values in a supplied array. String.length reports the number of UTF-16 code units.
Example. A student creates a small marks calculator. It takes two numbers, chooses an action based on the input and displays a result. The student tests normal numbers and invalid text separately to see which part of the program handles each case.
The important point is what “Finally block” does in a specific situation. To see the difference between this idea and the others in this chapter, compare what each one affects and which result would show that it had been used correctly. Use one concrete detail, such as a number, file name, message or action, to show exactly what you mean and how someone could check it.
175 words
7 Distinguish between Scanner and Arrays.sort.
Scanner can parse input from sources such as the console. Arrays.sort orders values in a supplied array.
Trace Java code in the order it executes. Keep track of the type and value of each variable, which condition is evaluated and how the result is returned or shown. String.length reports the number of UTF-16 code units. Try block contains code whose exceptional outcomes can be handled. Catch block handles a matching exception.
Example. A student creates a small marks calculator. It takes two numbers, chooses an action based on the input and displays a result. The student tests normal numbers and invalid text separately to see which part of the program handles each case.
Compare the two ideas using the same situation. Describe which part of the situation each idea explains and how the result would differ if you used the other one. This gives the distinction a clearer basis than listing two definitions in isolation.
157 words
Reference book: 802-Information Technology Class- XII_PART_B.pdf