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

Explain the importance of throwable class and its methods?

1 Answers  


what value will be return by the read() method once it reaches the end-of-file? a. Throws EOException b. Return null c. Return -1 d. Read method return nothing, because it is void method

1 Answers  


C and C++ has constructors and distructors, why does Java does not have distructors?

1 Answers   T3 Softwares,


When throws keyword is used?

1 Answers  


How java is platform independent?

41 Answers   College School Exams Tests, Infosys, TCS,


what is data binding? give the example

1 Answers   TCS,


Explain JPA in Java.

1 Answers  


How will you get the platform dependent values like line separator, path separator, etc., ?

1 Answers  


Why pointers are not used in java?

1 Answers  


What is a condition in programming?

1 Answers  


How do you identify independent and dependent variables?

1 Answers  


System.out & System.in are final static data member of System class but we can change there reference through setOut() & setIn() method how...

2 Answers   FCS, TCS,


Categories