About Question enthuware.ocajp.i.v7.2.1133 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
rafaparche
Posts: 5
Joined: Tue Apr 14, 2015 9:32 am
Contact:

About Question enthuware.ocajp.i.v7.2.1133 :

Post by rafaparche »

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!

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1133 :

Post by admin »

Not necessarily. You can throw any exception including RuntimeException using a throw statement.

leonardofaria00
Posts: 3
Joined: Fri Aug 09, 2019 11:21 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1133 :

Post by leonardofaria00 »

A resposta correta seria: Throwable, Exception e RuntimeException?

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1133 :

Post by admin »

Can you write it in English please?

girishankaran
Posts: 10
Joined: Wed Aug 08, 2012 5:00 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1133 :

Post by girishankaran »

The correct answer would be: Throwable, Exception and RuntimeException

Deleted User 6318

Re: About Question enthuware.ocajp.i.v7.2.1133 :

Post by Deleted User 6318 »

Exception and Error are two main subclasses of Throwable.
What are the other subclasses?

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1133 :

Post by admin »

There are several but not direct. Updated the explanation to make it clearer.

thanks for the feedback!

labutis
Posts: 2
Joined: Thu Mar 09, 2023 3:39 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1133 :

Post by labutis »

You can only throw a Throwable using a throws clause
Is this true? It seems that I can throw new Throwable(), just like with any other exception.

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1133 :

Post by admin »

labutis wrote:
Thu Mar 09, 2023 3:41 pm
You can only throw a Throwable using a throws clause
Is this true? It seems that I can throw new Throwable(), just like with any other exception.
Yes, it is correct. You quoted only half of the sentence. The complete sentence written in the explanation is:
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.
Please check the part written within the parentheses. That should make it clear.

labutis
Posts: 2
Joined: Thu Mar 09, 2023 3:39 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1133 :

Post by labutis »

Thanks!
From the explanation, I got the impression, that
you can only throw a Throwable object using a THROWS clause,
but I should've read It
is you can only throw a THROWABLE object using a throws clause
:)

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests