Explain try and catch exception in java, JAVA Programming

Assignment Help:

Explain try and catch exception in java?

Why use exceptions instead of return values?
1. Forces error checking
2. Cleans up your code through separating the normal case from the exceptional case. (The code isn't littered along with a lot of if-else blocks checking return values.)
3. Low overhead for non-exceptional case

Traditional programming languages set flags or return bad values such as -1 to denotes problems. Programmers frequent don't check these values.

Java throws Exception objects to denotes a problem. These cannot be ignored.
try-catch
try-catch
public class HelloThere {

public static void main(String[] args) {

try {
System.out.println("Hello " + args[0]);
}
catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Hello Whoever you are.");
}

}


Related Discussions:- Explain try and catch exception in java

Explain about core java, Java is increasingly used for middleware applicati...

Java is increasingly used for middleware applications to communicate among Server and clients. Java has features like multithreading, portability and networking capabilities. Chang

What is bean factory, A BeanFactory is like a factory class that having a c...

A BeanFactory is like a factory class that having a collection of beans. The BeanFactory holds Bean Definitions of multiple beans within itself and then instantiates the bean whene

I need gpa calculating application, I need GPA calculating application P...

I need GPA calculating application Project Description: My project is one of the GPA calculating application, Colleges have 37 courses or departments, engineering results alw

Explanation of the inputstream with suitable diagrams, Problem 1) Descr...

Problem 1) Describe the concept of interfaces in Java with a suitable example for the same Explanation of the concept of interfaces with example 2) Describe the Inp

Need to code using java in netbeans for my dissertation, I need to code usi...

I need to code using java in netbeans for my dissertation which is in data mining domain...deals with privacy preserving of sensitive rules or items using association rule hiding

Brute force search, how to implement brute foce in a program?

how to implement brute foce in a program?

How are this () and super() used with constructors, How are this () and sup...

How are this () and super() used with constructors? this() Constructors: is used to pointing current class instance. Can be used with methods or variables. Used to call

Object and Instance, What is the difference between instance and object of ...

What is the difference between instance and object of a class? Few says both are same, then why java kept both the words for same thing?

Where the local varible declared, Where the local varible declared? Dec...

Where the local varible declared? Declaring variables within a function, makes them local .They are available only within that function and hold no meaning outside of it

Explain java flow control, Explain java flow control ? if els...

Explain java flow control ? if else else if while for do while switch case break continue goto is a reserved word.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd