answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

What types of values can be thrown in java?

Only instances of subclasses of throwable can be used in conjunction with the throw keyword. In java all exceptions and errors are subclasses of throwable.


How many constructors does class Exception have?

The Exception class has 4 constructors. They are: a. Exception() b. Exception(String arg) c. Exception(String arg, Throwable arg1) d. Exception(Throwable arg)


What is the top most class in Exceptions?

All exception types are sub classes of the built-in class Throwable. so at the top most position it is Throwable --- under this comes two branches Exception and Error.


What is the difference between catch exception e catch error err and catch throwable t?

In Java it is related to the class hierarchy of exceptions. Throwable is the root object of the heirarchy, and both Exception and RuntimeError subclass it. Methods include a "throws" clause in their signature to indicate errors of type "Exception" that can be thrown in the body of the method and returned to the caller. Errors of type RuntimeError do not need to be reported in the throws clause.Exceptions are also called "checked" errors, and RuntimeErrors are called "unchecked." This simply means that methods that throw checked errors must declare them in the signature.* Exception: this is a "checked" error. Usually, this is some sort of data error that can be handled by the method. An example is FileNotFoundException - some code didn't an expected file, but the program may be perfectly capable of going on.* Error: A more serious problem that a program probably can't deal with. An example is OutOfMemoryError - when there is no more memory, there isn't much you can do about it and not much point in continuing.* Throwable: Superclass of both Error and Exception.So the main difference is that* 'catch Exception' will catch just exceptions (the problems you might deal with)* 'catch RuntimeError' will catch just errors (the problems you probably can't deal with)* 'catch Throwable' will catch all errors.Generally, you want to catch Exception or Throwable, but not RuntimeError. You will only want to catch Throwable if there is a requirement that the method never throw an error back to the caller.See related link to the Java API, and browse the documentation and subclasses of Throwable.


What is the difference between throw and throws in Java?

Throw is used to actually throw the exception, whereas throws is declarative for the method. They are not interchangeable.public void myMethod(int param) throws MyException{if (param < 10){throw new MyException("Too low!);}//Blah, Blah, Blah...} The Throw clause can be used in any part of code where you feel a specific exception needs to be thrown to the calling method.If a method is throwing an exception, it should either be surrounded by a try catch block to catch it or that method should have the throws clause in its signature. Without the throws clause in the signature the Java compiler does not know what to do with the exception. The throws clause tells the compiler that this particular exception would be handled by the calling method.

Related Questions

What types of values can be thrown in java?

Only instances of subclasses of throwable can be used in conjunction with the throw keyword. In java all exceptions and errors are subclasses of throwable.


Which boat is required to carry one Type IV throwable PFD?

16 feet or longer powerboat is required to carry one type IV throwable PFD.


Is a disadvantage of a Type IV Throwable Device PFD?

c


Can you catch multiple throwables in a try catch statement in Java?

Yes, the format of a try/catch/finally block is: try{ // Do Code } catch (Throwable A) { // Process throwable/exception } catch (OtherThrowable B) { // Process throwable/exception } // ... and so on and so forth, catching as many different catches as needed finally{ // Code you always want to execute, whether breaking out of a try // statement normally or by catching a throwable. // For example, close database connections or file handles here. }


How many constructors does class Exception have?

The Exception class has 4 constructors. They are: a. Exception() b. Exception(String arg) c. Exception(String arg, Throwable arg1) d. Exception(Throwable arg)


What is the top most class in Exceptions?

All exception types are sub classes of the built-in class Throwable. so at the top most position it is Throwable --- under this comes two branches Exception and Error.


Can you throw grenades in Team Fortress 2?

No, there are no throwable grenades in Team Fortress 2


Which vessels also must have one Type IV (throwable) PFD on board?

16 feet


Can anyone help suggest any mods in Minecraft that are realistic-like?

there is the throwable bricks mod


What is a rare fossil for on Pokemon explorers of sky?

They are throwable items like Gravelerocks, and deal 100 damage.


In addition to pfd what other equipment must be on board of a vessel 16 feet or longer?

throwable PFD


What does Gardevior do in Super Smash Bros. brawl?

Gardevior deflects projectile attacks, such as Samus's Missile, and throwable items, such as Pok&eacute;balls.