About Question enthuware.ocajp.i.v7.2.1133 :
Moderator: admin
-
- Posts: 5
- Joined: Tue Apr 14, 2015 9:32 am
- Contact:
About Question enthuware.ocajp.i.v7.2.1133 :
Question ask about what kind of objects can be thrown using a throw statement? Throwable and Exception are obvious but RuntimeException is thrown by jvm not by user, isn't?
Thanks!
Thanks!
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1133 :
Not necessarily. You can throw any exception including RuntimeException using a throw statement.
If you like our products and services, please help us by posting your review here.
-
- Posts: 3
- Joined: Fri Aug 09, 2019 11:21 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1133 :
A resposta correta seria: Throwable, Exception e RuntimeException?
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1133 :
Can you write it in English please?
If you like our products and services, please help us by posting your review here.
-
- Posts: 10
- Joined: Wed Aug 08, 2012 5:00 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1133 :
The correct answer would be: Throwable, Exception and RuntimeException
-
- Posts: 61
- Joined: Sat Feb 15, 2020 8:56 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1133 :
What are the other subclasses?Exception and Error are two main subclasses of Throwable.
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1133 :
There are several but not direct. Updated the explanation to make it clearer.
thank you for your feedback!
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
-
- Posts: 2
- Joined: Thu Mar 09, 2023 3:39 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1133 :
Is this true? It seems that I can throw new Throwable(), just like with any other exception.You can only throw a Throwable using a throws clause
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1133 :
Yes, it is correct. You quoted only half of the sentence. The complete sentence written in the explanation is:
Please check the part written within the parentheses. That should make it clear.You can only throw a java.lang.Throwable object (i.e. an instance of Throwable or any of its direct or indirect subclasses) using a throws clause.
If you like our products and services, please help us by posting your review here.
-
- Posts: 2
- Joined: Thu Mar 09, 2023 3:39 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1133 :
Thanks!
From the explanation, I got the impression, that
From the explanation, I got the impression, that
but I should've read Ityou can only throw a Throwable object using a THROWS clause,
is you can only throw a THROWABLE object using a throws clause
Who is online
Users browsing this forum: No registered users and 113 guests