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

Gameplay software, Individual Assignment Rework Asteroids to have a di...

Individual Assignment Rework Asteroids to have a different gameplay In the previous assignments, we have developed an Asteroids game. In this assignment, we are going to u

Design a game in java, Ten pigs were all in a pen, enjoying their morning s...

Ten pigs were all in a pen, enjoying their morning slop when a bird flew down from a nearby tree and began picking all the best bits out from the trough. This greatly perturbed the

Upload a file in struts? , In JSP page give the code as given below: en...

In JSP page give the code as given below: enctype="multipart/form-data" name="fileForm" scope="session">     Please select file here that you would like to upload:

Prepare simple spring maven task, Prepare Simple spring maven task Proje...

Prepare Simple spring maven task Project Description: We want a very simple delivery for one of our tasks using Spring STS Maven project. This chat does not have UI interf

Convert encrypted hsql database into csv format, Project Description: We...

Project Description: We have an encrypted HSQL Database which we need to convert into CSV format. HSQL DB . We have java application jar file which reads that database but no

Explain any five buzz words in java, Question 1 Explain any five buzz word...

Question 1 Explain any five buzz words in Java Question 2 Explain exception classes and also explain common exceptions in java Question 3 Explain primitive and abstract data t

Develope a simple polling web application, Develop a simple polling (voting...

Develop a simple polling (voting) web application according to the following specifications: Initially a page should be presented to the user where he can enter his/her name

Retrieving data from Excel file , how to retrieve data from Excel file, and...

how to retrieve data from Excel file, and display that data in table on jsp page?

SMALLTALK PROGRAMING, YOUR EXPERT CAN DEAL WITH SMALLTAK PROGRAMMING AND BP...

YOUR EXPERT CAN DEAL WITH SMALLTAK PROGRAMMING AND BPMN AND DoME BECAUSE I HAVE PROJECT RELATED WITH THIS PROGRAMING

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