1.
The predefined classes within the Java system, which provides an effective support to the
programmers in developing their program logic are known as library classes. There are number of
library classes and each class includes various functions. Some library class are java.io, java.util,
java.lang, java.awt, java.net, java.applet, etc.
2. The input stream function to take character as input is as follows:
a=System.in.read();
The output stream function to display the output is as follows:
System.out.print(x);
3. Different I/O strems used un Java programming are: System.in, System.out and System.err
4. Exception handling is a powerful mechanism to handle runtime errors so that normal flow of the
program can be maintained. Exception normally disrupts the normal flow of execution of the
program. Exceptions can be handled by using try‐catch block and throws keyword.
5. try{ }: try block contains a block of program statements within which an exception might occur. A
try block is always followed by a catch block, which handles the exception that occurs in associated
try block.
catch{ }: catch block must be associated with a try block. The corresponding catch block executes
if an exception of a particular type occurs within the try block.
6. Whenever an I/O errors occurs within a method, the method creates an object and hand it off to
the runtime system. The object, called exception object, contains information about the error
including its type and state of the program when error occurred. After a method throws an
exception, the runtime system attempts to find handler known as throws I/O exception to
eliminate the probable errors.
7. A wrapper class is a member of java library java.lang. It wraps the primitive data values in an
objects and provides a conversion system from character/string type to primitive and vice‐versa.
e.g. Integer, Character.
8. Java contains extensive library of pre‐written classes that we can use in our programs. These
classes are divided into groups called packages. Various packages in Java are: java.applet,
java.awt, java.io, java.lang, java.new, java.util etc.
9. Advantages of exception handling are:
a. It allows us to control the normal flow of program by using exception handling in program.
b. It throws an exception whenever a calling method encounters an error providing that the
calling method take care of that error.
10. import RESULT.marks.*;
class Eng
{
}
11.
a. java.lang
b. import
c. throw
12. Math class. e.g. double a=Math.pow(3,2);
13.
a. int x=275;
String s=Integer.toString(x);
b. String s=”275”;
int x=Integer.pareseInt(s);
c. int total=1000;
total=total+x
14.
a. java.lang
b. double x=0.732;
String s=Double.toString(x);
15. Uses of exception handling in Java are:
a. Exception handling separates error‐handling code from normal code.
b. It clarifies the code and enhances readability.
c. It stimulates consequences as the error‐handling takes place at one place and in one
manner.
d. It makes for clear, robust, fault‐tolerant programs
16. An Exception is an error which occurs during the execution of a program. The exception handling
blocks are try, catch and finally.
17. Catch block catches any error that had occurred in try block and thus prevents any termination of
the execution of the program due to an exception. It appears after the try block in a program