how and when compiler knows that the Java code throws the
checked Exception.

Answers were Sorted based on User's Feedback



how and when compiler knows that the Java code throws the checked Exception...

Answer / aruna

Checked or caught exceptions are those exceptions that the
application programmer created a catch block to handle them.
while compiling, the java compiler make sure that all the
checked exceptions must be caught by the applicaion
programmer.Those exceptions are called the application or
business logic exceptions.

Inside the method body, there are calls to other methods;
the compiler looks at each of their method signature, what
exceptions they declared to throw. There are two
possibilities, either exceptions are caught inside the
caller-method by a try-catch block, or the caller declares
to throw the exception to its caller.

Is This Answer Correct ?    18 Yes 4 No

how and when compiler knows that the Java code throws the checked Exception...

Answer / vatsal doshi

When: At Compile Time

How: Complicated.

Checked Exceptions are those which a Java Compiler is capable of checking at compile time. These exceptions normally occur when some pre-definite methods from the Java API are used by programmer. So compiler identifies such method invocations in the code. If handled using catch, or specified in the throws clause, compiler compiles successfully. Otherwise, it shows a Compile Time Error Message of possibility of a Checked Exception

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More Core Java Interview Questions

What are advantages and disadvantages of OOPs?

0 Answers   Amdocs,


What is a variable in java?

0 Answers  


How many types of interfaces are there?

0 Answers  


How do you declare an array that will hold more than 64KB of data?

0 Answers   Aspire, Infogain,


What are the 2 types of java programs?

0 Answers  






why we r not use pointers in corejava?

2 Answers   Samsung,


Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx

0 Answers  


Why is the main method static?

0 Answers  


Why does it take so much time to access an applet having swing components the first time?

0 Answers  


What are the Class Libraries ?

0 Answers   Wipro,


What are the 8 data types in java?

0 Answers  


What is the purpose of static methods and static variables?

0 Answers  


Categories