Exercise 11.1 Write a code fragment that performs the same function as the statement below without using the crash method Toolbox.crash(amount < 0,

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Chapter 16 Exception Handling. What is Exception Handling? A method of handling errors that informs the user of the problem and prevents the program from.
Exceptions: when things go wrong. Various sources of error public static doSomething() { int i = 3.0; while(!done); { int i = false } ) Syntactic errors.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Introduction to C# Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Exceptions Any number of exceptional circumstances may arise during program execution that cause trouble import java.io.*; class IOExample { public static.
Slides prepared by Rose Williams, Binghamton University ICS201 Exception Handling University of Hail College of Computer Science and Engineering Department.
Exceptions Three categories of errors: Syntax errors Runtime errors Logic errors Syntax errors: rules of the language have not been followed. Runtime error:
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
Exceptions 1. Your computer takes exception Exceptions are errors in the logic of a program (run-time errors). Examples: Exception in thread “main” java.io.FileNotFoundException:
Chapter 9: Exceptions For error/problem situations Exception classes –ArithmeticException, IOException, etc. –checked exceptions try blocks –catch statements.
Exception Handling in JAVA. Introduction Exception is an abnormal condition that arises when executing a program. In the languages that do not support.
Exceptions CSC 171 FALL 2004 LECTURE 24. READING Read Horstmann Chapter 14 This course covered Horstmann Chapters
1 BUILDING JAVA PROGRAMS CHAPTER 6 FILE PROCESSING.
BUILDING JAVA PROGRAMS CHAPTER 1 ERRORS. 22 OBJECTIVES Recognize different errors that Java uses and how to fix them.
BIO Java 1 Exception Handling Aborting program not always a good idea – can’t lose messages – E-commerce: must ensure correct handling of private.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
JAVA COURSE LESSON2 BY OMPUTER ENGINEEING ASSOCIATION.
Programming and Problem Solving With Java Copyright 1999, James M. Slack Exceptions Handling Exceptions with try and catch The finally-block The throws.
1 Features of Java (2) CS 3331 Sections 4.5 and 4.6.
Java FilesOops - Mistake Java lingoSyntax
CSE 1020: Exceptions and A multiclass application Mark Shtern 1-1.
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
Throw, Throws & Try-Catch Statements Explanations and Pictures from: Reference:
1 Text File Input and Output. Objectives You will be able to Write text files from your Java programs. Read text files in your Java programs. 2.
Lab 6 Instructions You can use g++ on build server, visual studio on local machine or your preferred C++ IDE. Important Note: For your grade, please show.
Java Exceptions a quick review….
Exceptions: When things go wrong
Chapter 10 – Exception Handling
JavaScript - Errors & Exceptions Handling
Chapter 12 Exception Handling And Text IO
Building Java Programs
Maha AlSaif Maryam AlQattan
CS1101: Programming Methodology Recitation 7 – Exceptions
Introduction to Exceptions in Java
RADE new features via JAVA
Introduction to OO Program Design
Chapter 14 - Exception Handling
Code Magnets problem for wk5
Testing and Exceptions
CS Week 10 Jim Williams, PhD.
Handling Exceptions.
Object Oriented Programming
Advanced Programming Behnam Hatami Fall 2017.
PROGRAM STRUCTURE CSC 111.
مظفر بگ محمدی دانشگاه ایلام
Exceptions & exception handling
Building Java Programs Chapter 6
مظفر بگ محمدی دانشگاه ایلام
File I/O ICS 111: Introduction to Computer Science I
Exception Handling in Java
Exception Handling CSCI293 - C# October 3, 2005.
TRY CATCH BLOCK By Kosala Rajapaksha.
Input/output (I/O) import java.io.*;
Exception Handling in Java
CS 180 Assignment 6 Arrays.
CMSC 202 Exceptions 2nd Lecture.
Ninth step for Learning C++ Programming
Errors and Exceptions Error Errors are the wrongs that can make a program to go wrong. An error may produce an incorrect output or may terminate the execution.
Tenth step for Learning C++ Programming
Exception Handling Contents
Exceptions.
Debugging Exercise 00 Try compiling the code samples.
Exceptions References: Jacquie Barker, Beginning Java Objects; Rick Mercer, Computing Fundamentals With Java; Wirfs-Brock et. al., Martin Fowler, OOPSLA.
Java Basics Exception Handling.
Exception Objects An exception is an abnormal condition that arises in a code sequence at rum time. Exception is a way of signaling serious problem.
Exceptions.
Basic Exception Handling
How to Run a Java Program
Presentation transcript:

Exercise 11.1 Write a code fragment that performs the same function as the statement below without using the crash method Toolbox.crash(amount < 0, “A negative amount!”);

Exercise 11.2 Locate the error and specify if it is compile-time, runtime, or logic try { // some code } catch (java.io.IOException e) catch (java.io.FileNotFoundException e)

Exercise 11.3 try { // some code } catch (Exception e) {} Explain what is wrong with the following try { // some code } catch (Exception e) {}

Exercise 11.4 Critique the following and compare to the previous exercise public static void main (String[] args) throws Exception