IAT2 ANSWER KEY
IAT2 ANSWER KEY
PART-B
A chained exception is created by wrapping an existing exception in a new exception, which becomes the
root cause of the new Exception.
The new Exception can provide additional information, while the original Exception contains the actual
error message and stack trace.
11.b.Outline the states a thread can be in and specify the rules that determine when a context switch takes
place.
Context switching in an operating system involves saving the context or state of a running process so
that it can be restored later, and then loading the context or state of another. process and run it.
(or)
12.b. Differentiate Generic class and Generic Interface with example.
Interfaces, on the other hand, are a way of defining the structure of an object. They allow you to specify
the shape of an object and its properties and methods, without actually creating an object. Interfaces are
denoted by the interface keyword.
13.a.Java exception handling is managed via five keywords. Name the five key words and present an
outline of an exception-handling block with syntax. How user defined Exception is created and caught
using Java Programming.
Five keywords are used in exception handling: try, catch, finally, throws and throw (take note that there is
a difference between throw and throws).
Java’s exception handling consists of three operations:
1. Declaring exceptions;
2. Throwing an exception; and
3. Catching an exception.
(or)
13.b.Present an outline of the methods used by Java for inter process communication
1. Pipes: A pipe is a unidirectional communication channel used for IPC between two related
processes. One process writes to the pipe, and the other process reads from it.
2. Message Queues: Message queues are used to send and receive messages between processes. They
can be used for both one-to-one and one-to-many communication.
3. Shared Memory: Shared memory is a technique where multiple processes can access the same
region of memory. This allows for high-speed communication between processes.
14.a.List and Explain Data types and their corresponding Wrapper class
For each data type, Java provides a predefined class called Wrapper Class.
Wrapper classes wrap primitive data type value into a class object. It is this wrapper class that helps to
make Java object-oriented.
All the Wrapper classes present in Java are present inside java.lang package. And java.lang package is the
default package in Java.
14.b.What is Input Stream? . How the methods defined by Input Stream are used?. Explain it with an
example.
InputStream is used for reading, OutputStream for writing. They are connected as decorators to one
another such that you can read/write all different types of data from all different types of sources.
How to perform reading and writing files ? Explain with example
!/usr/bin/python
# Open a file
fo = open("foo.txt", "wb")
fo.write( "Python is a great language.\nYeah its great!!\n")
# Close opend file
fo.close()
15.a.Why parameterized types are important? Outline Java generics with an example
Generics means parameterized types. The idea is to allow type (Integer, String, … etc., and user-
defined types) to be a parameter to methods, classes, and interfaces. Using Generics, it is possible to
create classes that work with different data types. An entity such as class, interface, or method that
operates on a parameterized type is a generic entity.
if(style == style2)
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}