Exceptions or OCA Flashcards

1
Q

how many types of exceptions to be recognized

A

runtime exceptions, checked exceptions and errors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is exception

A

is an event alters the program flow, un wanted event

when occur in execution the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

exceptions are objects?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

behind the exceptions generating?

A
  1. object created by the JVM

2. thrown to the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

throw keyword?

A
is used throwing the exception manually,
throw aib(object name)--->JVM by using this keyword 
we can see the exception code in councel.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how could be prove that exceptions are class and throw keyword

A
for ex;  ArithmeticExceptions art= new ArithmeticExceptions();
throw art; // JVM how throw it to program.....
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the try keyword—-(try catch block)

A

try {

some code written} catch (name of the exceptions subject name)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

if we change the catch- with other exceptions does it work?

A

no it does not catch anything,-so IndexOutOfBOund Exceptions- not catch the Arithmetics Exceptions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

can I add second catch block-multi catch buyer?

A

yes, it is goingto be same, catch() System.out…

catch()System out….

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is the more one to cover all exceptions like arithmetics, indexoutof bound…

A

Exception—instead of arithmeticsExceptions, replace the exceptions…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

how many types exceptions

A
uncheked exceptions(runtime exceptions)
checked exceptions(Exception and subclasses)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

handle or declare rule

A

Java requires the code either handle or declare in the method signature

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

difference between Errors and Exception?

A
Errors indicate serious problems that does not try and catch, Exceptions indicates the situation that can try and catch_
both is child class of throwable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Exceptions—Checked?runtime exceptions

A

Checked exception must be handled before we can run the program. If ignored then program won’t compile.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Unchecked Exceptions/Runtime Exception

A

Type of exception where will be thrown during runtime.

It is very challenging to predict. Because it won’t complain during compile time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

how handle exceptions

A

throws Exception,

try and catch block

17
Q

multiple Catch block rules

A

When using multiple catch blocks, Parent Exception type MUST be used in the end. Otherwise child exception catch blocks will be ‘Unreachable code’ and it won’t be compiled.
​Use pipe line ”|” between exceptions when throwing multiple exceptions.
​if there are multiple catch block, when exception is caught by first catch block, rest of the catch block will NOT catch any exception.

18
Q

difference between throw and throws?

A

throw –> explicitly creating exception(tell Java that u want throw the exception
throws –> passing the exception to next user to handle(that the method might throw an exception

19
Q

adding finally block

A

try{//code} catch(exception identifielder){} finally{}
if exceptions is thrown finally block run after catch block;
no exceptioons is thrown after try block complete

20
Q

Run time exceptiosn

A

ArithmeticExceptions/IndexOutofBound Exception/NullPointerException/

21
Q

Checked Exceptions

A

IOException/FIleNotFoundException

22
Q

Errors

A

Errors extend the Error class. StackOverFlowError,NoClassDeFoundError/

23
Q

sample for writing throw keyword

A
throw new Excep();
throw new Excep("oh hey");
24
Q

how to read the code

A

start top try block and ctach if there is any exceptions of not pass to the finally blocks

25
Q

which exceptions handle by the JVM

A

Aritmethic Exc—divided by 0;
ArrayIndexOutOfBounds—illegal index
ClassCastExceptions–cast an objto suclass not instance
NullPointerException—

26
Q

Runtime Exceptiond/Uncheked

A

not have be handled or declared