Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Sale notes online your Nr 1 Resource,for passing Exam at VCU

Rating
-
Sold
-
Pages
11
Grade
A+
Uploaded on
02-08-2023
Written in
2023/2024

I've written dozens of study guides for all my this material you'll be sure to pass your exams,Questions? Don't hesitate to send me messages

Institution
Course

Content preview

EXCEL ENGINEERING COLLEGE
(Autonomous)
COMPUTER SCIENCE AND ENGINEERING
III Semester
20CS302 – OBJECT ORIENTED PROGRAMMING
Regulations 2020
Question Bank with Answer Key
UNIT – III (APPLETS, EXCEPTION HANDLING AND I/O)
PART- A
Q.No Questions
Define Exception.
1  A Java exception is an object that finds an exceptional condition occurs from a piece of code.
 An exception object is created and thrown to the method from the code where an exception is found.
Recall the purpose of exception handling mechanism.
 The main purpose of exception handling mechanism is used to detect and report an “exceptional
circumstance” so that necessary action can be taken. It performs the following tasks
 Find the problem(Hit the exception)
2
 Inform that an error occurred(throw the exception).
 Receive the error information(Catch the exception)
 Take corrective actions(Handle the exception)

What are the types of exceptions?
 There are two types of exceptions
3  Predefined Exceptions-The Exceptions which are predefined are calledpredefined exceptions
 Userdefined Exceptions- The Exceptions which are defined by the userare called userdefined exceptions

How the exception handling is managed?
 Java exception handling is managed via five keywords.
 try
4  catch
 throw
 throws and
 finally

Write down the general form of an exception-handling block.
 The general form of an exception-handling blocktry
{
// block of code to monitor for errors
}
catch (ExceptionType1 exOb)

5 {
// exception handler for ExceptionType1

}
catch (ExceptionType2 exOb)

{
// exception handler for ExceptionType2

, }
// ...
finally
{
// block of code to be executed after try block ends
}

List out the two subclasses under Throwable class.
 Throwable is a superclass for all exception types. Thus, Throwable is at topof the exception hierarchy.
 There are two subclasses under Throwable class.
6
 Exception
 Error

What is an Error?
 The another subclass is by Error, which defines exceptions that are notexpected to be caught under
normal circumstances by your program.
7  Exceptions of type Error are used by the Java run-time system to indicateerrors having to do with the run-
time environment, itself.
 Eg: Stack overflow is an example of such an error.

Identify the situation where we need to use multiple catchclauses.
 In some situation, more than one exception can occur by a single piece of code.
 To handle this situation, we can use two or more catch clauses, each catching a different type of exception.
8 When an exception is thrown, each catch block is executed in order, and the first one whose type matches
that exception is executed.
 After one catch block executes, the others are bypassed, and continues after the try/catch block.

Why we need to use nested try statements.
 The try statement can be nested. That is, a try statement can be inside the block of another try.
 Each time a try statement is entered, the context of that exception is pushed on the stack.
 If an inner try statement does not have a catch handler for a particular exception, the stack is unwound
9
and the next try statement’s catch handlers are inspected for a match.
 This continues until one of the catch statements succeeds, or until all of the nested try statements are
exhausted. If no catch statement matches, then the Java run-time system will handle the exception.

Write down the use of throws clause.
 Using throws clause, We can list the types of exceptions that a method might throw.
10  The exceptions which are thrown in a method might be using throws clause. If they are not, a compile-time
error will result.

Give the use of finally clause.
 Finally creates a block of code that is to be executed after a try/catch block has completed its execution.
 The finally block will execute if an exception is thrown or not thrown.
11
 The finally clause is optional.
 Each try block requires either one catch or a finally clause

Define Unchecked Exception.
 These are the exceptions that are not checked at compiled time.
12  In C++, all exceptions are unchecked, so it is not forced by the compiler to either handle or specify the
exception.
 It is up to the programmers to be civilized, and specify or catch the exceptions.

Connected book

Written for

Course

Document information

Uploaded on
August 2, 2023
Number of pages
11
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$12.79
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
vengatedits

Get to know the seller

Seller avatar
vengatedits Excel Engineering College
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
19
Last sold
-
Sale notes online your Nr 1 Resource,for passing Exam at VCU

I've written dozens of study guides for all my this material you'll be sure to pass your exams,Questions? Don't hesitate to send me messages

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions