Forums Register Login

exception

+Pie Number of slices to send: Send
when am practicing mock exams found this question please clarify it?

question:which of them is often thrown by the developer?
answer:numberformatexception


whether numberformatexception is checked or unchecked?
is it possible for developer to throw both checked and unchecked?
+Pie Number of slices to send: Send
Your question makes no sense. You appear to have omitted a large portion of information in your question.
1
+Pie Number of slices to send: Send
The following page in Oracle's Java Tutorials explains the three types of exceptions, and how to know whether an exception is a checked exception or not:

The Catch or Specify Requirement

After studying this, can you tell us if NumberFormatException is a checked or unchecked exception?
+Pie Number of slices to send: Send
… and what did you think was the answer to your third question?
+Pie Number of slices to send: Send
 

bairava surya wrote:
question:which of them is often thrown by the developer?
answer:numberformatexception


I think you mean it is caught by the developer, not thrown?

The answers to your other two questions should be rather simple to find.
+Pie Number of slices to send: Send
this is the exact question!my doubt is all the exceptions can be thrown by the developers why only these options are correct?
Capture.PNG
image
[Capture.PNG]
+Pie Number of slices to send: Send
Well, yes, the developer can certainly write Java code which throws any of those exceptions. But not all of the options are correct because that isn't the question. Read the question again and you'll find it is significantly different from the question "Which of these exceptions can be thrown by an application developer or an API developer?"
+Pie Number of slices to send: Send
is there any other exceptions thrown by the developers?
+Pie Number of slices to send: Send
Well, yeah. Have a look at the API documentation. There are hundreds of exceptions which can be thrown by developers. However if you're studying for one of those exams you won't be required to memorize the whole enormous list.
+Pie Number of slices to send: Send
You must tell us where that question is from, please.

I think your answer to the question asked is incorrect. Part of the technique for success in exams is reading the question correctly. You have answered a different question from what was actually asked (as Paul C has already told you), so I believe you will score −1 on that example.
+Pie Number of slices to send: Send
I got this question from oracle java press exams(cd kathy sierra,bates) please provvide me the correct solution?provide me some useful link to know about the exceptions thrown by the developers?
+Pie Number of slices to send: Send
Which Exceptions do you think a developer would write? You are looking for code like this:-What sort of Exception would you want there?

And thank you for telling us where the question is from.
+Pie Number of slices to send: Send
just my placing the XYZ exception in the catch block we can handle the exception?As an developer we can throw all the exceptions (checked or unchecked)but in the above question why they opted only three?
+Pie Number of slices to send: Send
 

bairava surya wrote:just my placing the XYZ exception in the catch block we can handle the exception?As an developer we can throw all the exceptions (checked or unchecked)but in the above question why they opted only three?



Because the question asked "which are most commonly thrown by a dev", and not "which can be thrown by a dev".

As you say, a dev could write code to throw any of those, but that doesn't mean they are the sort of exceptions they should be throwing.
+Pie Number of slices to send: Send
Did they show three as the answer, or did you?

The question does not ask anything about catching Exceptions, only about throwing them. You would never throw an Exception and catch it in the same method. That is simply an inefficient way to wrote an if‑else.
+Pie Number of slices to send: Send
explain me how i can classify the exceptions that are thrown by the developers vs JVM?
+Pie Number of slices to send: Send
 

bairava surya wrote:explain me how i can classify the exceptions that are thrown by the developers vs JVM?


I don't know that you can. There are no specific rules to say a particular classification of exception can only be thrown by the JVM or by a developer.
Having said that it is often the case (but certainly not always) that Errors will be thrown the JVM and checked exceptions will be thrown by a developer. Other Exceptions such as Runtime exceptions can be thrown by either the JVM or Developer.
+Pie Number of slices to send: Send
You don't have to know how to classify exceptions which are typically thrown by the JVM versus those that developers would typically throw. You only have to know how to put an exception into one of those two categories when you're given its name.

And you have only five names given to you there. So instead of looking for some grand organizing principle you should just ask yourself when each of those exceptions might occur.

If you don't mind my saying so, it seems to me that you are approaching the task of learning Java in the wrong way. It seems to me that you have the idea that there is a big list of things that you have to memorize to pass an exam, and that once you have passed that exam then you will be a Java programmer. But that's not the case. For example in the question you posted, it was written because a Java programmer should know what a ClassCastException is for, and based on that knowledge should be able to answer that question.
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 885 times.
Similar Threads
Exceptions In Finalizers
difference between JVM thrown exceptions and programmatically thrown exceptions?
Confusion regarding exceptions thrown by Developer or by JVM
Jvm thrown exceptions & programmatically thrown exceptions
K&B Page 382 Exception
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:04:50.