Questions tagged [checked-exceptions]

The exceptions that need to be declared in a method or constructor's `throws` clause if they can be thrown by the execution of the method or constructor and propagate outside the method or constructor boundary.

The class Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch.

The class Exception and any subclasses that are not also subclasses of RuntimeException are checked exceptions. Checked exceptions need to be declared in a method or constructor's throws clause if they can be thrown by the execution of the method or constructor and propagate outside the method or constructor boundary.

Details: http://docs.oracle.com/javase/7/docs/api/java/lang/Exception.html

145 questions
-1
votes
1 answer

Final rethrow in Java: Exception Handling

I was going through some Exception Handling concepts in Java and came across the concept of final rethrow. I read the following…
ayush
  • 464
  • 5
  • 17
-1
votes
3 answers

Why we need to handle or throw checked exceptions in Java?

I am new to Java, I read that checked exception get raised during compile time only i.e. program will not compile successfully if there is a checked exception which is not handled or thrown. If something is preventing a compiler to compile a code,…
wholesome
  • 57
  • 9
-1
votes
2 answers

Java Checked Exception

I'm struggling figuring out something about checked Exception in Java. What I've learned (I may be wrong) is that if you throw a checked Exception you have two options. you have to catch it with try catch block you delegate the caller with the…
-1
votes
1 answer

Which Exception get priority Checked or Unchecked ? and Why?

I written my own two customized Exception one is checked and other is unchecked when i'm executing my code is shows only checked Exception Why i'm not able to get unchecked Exception output?? class Test { public static void main(String…
Rohit Maurya
  • 730
  • 1
  • 9
  • 22
-2
votes
2 answers

Kotlin ignoring CheckedException leads to potential bug source

The following method will warn about IOException if called in Java code but will simply ignore any warning in Kotlin because IOException is a checked exception. ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE) Java forces…
Farid
  • 2,317
  • 1
  • 20
  • 34
-2
votes
1 answer

Is Exception checked or not in JAVA?

Consider the following code public void myMethod1() { try { this.getClass().getMethod("myMethod").invoke(this); } catch (Exception e) { throw e; } } public void myMethod1_fixed() throws Exception { try { …
user1589188
  • 5,316
  • 17
  • 67
  • 130
-2
votes
1 answer

How do I resolve these exceptions?

To be fair, I'm not getting these exceptions but merely trying to find a away to cover these exceptions. The exceptions are NosuchElementException and NumberFormatException. Note: This programs works perfectly because the txt file is fine. However,…
Luis Averhoff
  • 385
  • 6
  • 22
-3
votes
1 answer

java ATM program simulation with exception handling - no error neither full output

the output is not a complete one, and neither are the exceptions handled. Please help. public class ATM { private String message; public ATM(String m) { if (m == null || m.trim().equals("")) throw new…
-3
votes
1 answer

Reference of all checked / unchecked exceptions in the standard API

I'm trying to learn about exceptions in Java and, for educational purposes, it would be nice if I could get hold of a reference of all checked exceptions and all unchecked exceptions in the standard API. Related question but not quite what I'm…
Sizons
  • 640
  • 2
  • 8
  • 24
-4
votes
1 answer

Why can't Java Lambda throw an checked exception

I'm learning Java and am a bit confused, why Lambda Expressions can't throw checked exceptions. Anyone has an understandable explanation for this? I read through this post: Java 8 Lambda function that throws exception? and this one: java throwing…
1 2 3
9
10