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 bean lifecycle in spring framework, 1. The spring container searche...

1. The spring container searches the bean's definition from the XML file and instantiates the bean. 2. Using the dependency injection, spring populates all of the properties as

Illustrate java management extensions (jmx)?, JMX framework can enhance the...

JMX framework can enhance the manageability of your application by  1. Monitoring your application for critical events, performance problems, and error condition statistics. E.g

What are the advantages of multimedia presentations, What are the advantage...

What are the advantages of multimedia presentations? Write any five. Multimedia presentation is a excellent tool for effective communication: Advantages: 1. Easy to make l

Prepare a game in corona for android and ios, Prepare a Game in Corona for ...

Prepare a Game in Corona for Android and IOS Project Description: We want to develop a game for mobile platform same as Zombie Smasher for iOS and Android. Everything is r

What is methods in java explain with an example, What is Methods in java ex...

What is Methods in java explain with an example? Data types aren't much use unless you can do things along with them. For this reasons classes have techniques. Fields say what

I want fitlife app for android - ios, I want FitLIFE app for Android, IOS, ...

I want FitLIFE app for Android, IOS, Windows Project Description: Hello, I want to develop an app for Android, IOS and Windows Phone. This app will be work with open source B

Visa resolve online - websphere administrator, Visa Resolve Online and Heal...

Visa Resolve Online and Health Care Project: Visa Resolve Online In this project there are few modules like TRANSACTION INQUIRY,CHARGEBACK , REPRESENTMENT, ARBITRATION .

List the keywords which are used in java 1.1, List the keywords which are u...

List the keywords which are used in java 1.1? The list of keywords which are used in java 1.1 are given below: Keyword Purpose boole

Why local variable is preferred over global variable, Why Local variable is...

Why Local variable is preferred over Global variable ? In my point of view Global variable has a few advantage along with Local variables is preferred because of the subsequent

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