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

IAT2 ANSWER KEY

CS3391 OOPS answer key

Uploaded by

priniravi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

IAT2 ANSWER KEY

CS3391 OOPS answer key

Uploaded by

priniravi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

AVS COLLEGE OF TECHNOLOGY, SALEM-106

Department of Information Technology


Internal Assessment Test – II (IAT – II)
Semester & Branch: III / Answer key Date: 23.11.23
IT (AN)
Subject Code &Name: CS3391/Object Oriented
Programming

1.State the difference between Exception and Error.


Exception – run time error
Error-syntax error

2.ention the purpose of finally class in Exception handling


The finally block in java is used to put important codes such as clean up code e.g. closing the file or
closing the connection. The finally block executes whether exception rise or not and whether exception
handled or not. A finally contains all the crucial statements regardless of the exception occurs or not.
3.What is Thread pool?
A thread pool is a collection of worker threads that efficiently execute asynchronous callbacks on behalf
of the application. The thread pool is primarily used to reduce the number of application threads and
provide management of the worker threads. Applications can queue work items, associate work with
waitable handles, automatically queue based on a timer, and bind with I/O.
4.List the importance’s of Synchronization.
Data synchronization ensures accurate, secure, compliant data and successful team and customer
experiences. It assures congruence between each source of data and its different endpoints. As data comes
in, it is cleaned, checked for errors, duplication, and consistency before being put to use.
5.Analyze the difference between String and String Buffer
Strin StringBuffer
g

1) The String class is immutable. The StringBuffer class is


mutable.

2) String is slow and consumes more memory StringBuffer is fast and


when we concatenate too many strings consumes less memory when
because every time it creates new instance. we concatenate t strings.

3) String class overrides the equals() method StringBuffer class doesn't


of Object class. So you can compare the override the equals() method
contents of two strings by equals() method. of Object class.

4) String class is slower while performing StringBuffer class is faster


concatenation operation. while performing
concatenation operation.

5) String class uses String constant pool. StringBuffer uses Heap


memory
6.Write the syntax to reverse the String “Happy”.
Conclusion. strrev() is a non-standard string library function in C language, which we can use to reverse a
string. The reversed string is stored in the same string ie, strrev() does not creates a new string, it reverses
and replaces the original string itself. Syntax : char *strrev(char *str);
7.How character streams are defined?
Character streams are defined by using two class hierarchies topped by these two abstract
classes: Reader and Writer. Reader is used for input, and Writer is used for output. Concrete classes
derived from Reader and Writer operate on Unicode character streams.
8.Give the syntax of Generic class with example.
Java Generics was introduced to deal with type-safe objects. It makes the code stable.Java Generics
methods and classes, enables programmer with a single method declaration, a set of related methods, a
set of related types.
9.Differentiate Autoboxing and Unboxing with example.
Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and
their corresponding object wrapper classes. For example, converting an int to an Integer, a double to
a Double, and so on. If the conversion goes the other way, this is called unboxing.
10.Recall the purpose of Wrapper class
A Wrapper class in Java is a class whose object wraps or contains primitive data types. When
we create an object to a wrapper class, it contains a field and in this field, we can store
primitive data types. In other words, we can wrap a primitive value into a wrapper class object.

PART-B

11.a.Write short notes on chained Exceptions

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.

12.a.Explain the methods available in String buffer class


1. StringBuffer objects are mutable, meaning that you can change the contents of the buffer without
creating a new object.
2. The initial capacity of a StringBuffer can be specified when it is created, or it can be set later with
the ensureCapacity() method.
3. The append() method is used to add characters, strings, or other objects to the end of the buffer.
4. The insert() method is used to insert characters, strings, or other objects at a specified position in the
buffer.
5. The delete() method is used to remove characters from the buffer.

(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.

15.b.Write a java program to compare two Strings.

public class CompareStrings {

public static void main(String[] args) {

String style = "Bold";


String style2 = "Bold";

if(style == style2)
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}

You might also like