Questions tagged [unchecked-exception]

In Java programming, an exception that does not need to be declared in a method's throws clause, and is not required to be caught.

RuntimeException is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine.

RuntimeException and its subclasses are unchecked exceptions. Unchecked exceptions do not 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/RuntimeException.html

63 questions
1
vote
4 answers

Customized Exception is checked or unchecked Exception?

Whether the Customized Exception is Checked or Unchecked Exception? How?
dgl viru
  • 177
  • 2
  • 5
1
vote
2 answers

Custom Unchecked Exceptions

Okay guys I've been trying to figure this out for the past day or so. My homework assignment has me creating both Unchecked and Checked Exceptions. The checked exceptions I believe I get basically they must be handled before compiling (With try &…
Joseph hooper
  • 967
  • 4
  • 16
  • 35
1
vote
2 answers

Facing java.lang.StackOverflowError on throwing unchecked exception from constructor

I was trying out to run the below code sample but getting StackOverflow error. It seems to stuck up in the infinite loop. Can anybody help me out in knowing what's going on in here? Please find below code snippet public class ConstructorExample { …
1
vote
1 answer

Why it is not recommended to handle unchecked exceptions by using try...catch blocks? Why only through some conditional checkings only?

Why it is not recommended to handle unchecked exceptions by using try...catch blocks? Why we need to avoid them through some conditional checkings only?
1
vote
1 answer

Compile-Time Checking of Exceptions. Case where finally block is throwing unchecked exception implicitly

The following code compiles perfectly. And I believe it's because the compiler knows at compile time that the control will go to the finally block and throw the unchecked exception (which is okay and doesn't require to be handled) and it knows that…
1
vote
2 answers

Java unchecked or unsafe operations message

I am getting the following error when compiling a Java class in BlueJ. AuctionManager.java uses unchecked or unsafe operations. This error is only displayed when the following deserialization code is in one of my functions: try { …
0
votes
0 answers

How to fix NoSuchElementException?

This is class Main. There are two more classes in the models(Contact, ContactManager) and a txt file(contact.txt) I have tried to load contacts from contacts.txt. This program was working and now it is not. I can not find the mistake or how can I…
0
votes
0 answers

Spring Boot + Spring Security. How do I trigger a RequestRejectedException?

For a simple Spring Boot app with Spring Security, I want to trigger a RequestRejectedException and see it in my console output. I think I'm able to trigger a runtime expection of this type, but no ERROR logging appears in my console. What I've…
0
votes
0 answers

Why Exceptions are categorized as Checked and unchecked?

I got one doubt regarding exception handling. We have checked and unchecked exceptions. Why they have given like that? irrespective checked or unchecked we have to handle the exception. Then i am unable to draw a line why that is given like…
0
votes
2 answers

Is it possible to throw an checked Exception implicitly, without any athrow instruction?

In Java, both checked exception and unchecked exception can be thrown explicitly, i.e, by a throw statement. Besides, unchecked exceptions like ArithmeticException and OutOfMemoryError can be triggered without any explicit throw statement like…
0
votes
0 answers

Catch a list of specific exception subtypes instead for unchecked exceptions

How do I determine what exception to use for unchecked exceptions? For example @Override protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) { LOG.info("Inisde FarmersLegalAuditJsonDataServlet do…
developers
  • 95
  • 3
  • 15
0
votes
1 answer

XMLStreamException: ParseError at [row,col] when opening new stage (new window)

I'm trying to switch from a window to another one. This is my code: public class SelectTypeController implements Initializable { @FXML private Button buttonVai; @FXML private ComboBox comboBox; @FXML private…
user14204888
0
votes
1 answer

Check if an exception is a checked exception at runtime

Is this the correct way to check if an exception is a checked exception at runtime? public boolean isChecked(final Throwable e) { return !(RuntimeException.class.isAssignableFrom(e.getClass()) ||…
user5132301
0
votes
0 answers

How to Anticipate Exceptions in C# When There Are No Checked Exceptions

In Java, calls to functions that can throw Exceptions need to anticipate them with either a try-catch or by adding a throws Exception to their function signature. My main use for them is in my top-calling code, where I only put try-catches in…
Floating Sunfish
  • 4,920
  • 5
  • 29
  • 48
0
votes
0 answers

What does it mean by propagating all exceptions in Java

I was told to propagate all exceptions. This sentence means active propagation such like : public void doSomething() throws SomeException{ try{ doSomethingThatCanThrowException(); } catch (SomeException e){ e.addContextInformation(�more…
Tonyukuk
  • 5,745
  • 7
  • 35
  • 63