CS12230 Introduction to Programming Lecture 6-2 –Errors and Exceptions 1.

Slides:



Advertisements
Similar presentations
Course Web Site – Also linked from Blackboard Course Materials – Excel Tutorials – Access Tutorials – PPT.
Advertisements

Exceptions: when things go wrong. Various sources of error public static doSomething() { int i = 3.0; while(!done); { int i = false } ) Syntactic errors.
CS 206 Introduction to Computer Science II 01 / 20 / 2009 Instructor: Michael Eckmann.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 13 Exception Handling.
Exceptions1 Syntax, semantics, and pragmatics. Exceptions2 Syntax, semantics, pragmatics Syntax –How it looks, i.e. how we have to program to satisfy.
EXCEPTIONS. What’s an exception?? Change the flow of control when something important happens ideally - we catch errors at compile time doesn’t happen.
Exceptions1 Syntax, semantics, and pragmatics. Exceptions2 Syntax, semantics, pragmatics Syntax –How it looks, i.e. how we have to program to satisfy.
Wednesday, 12/4/02, Slide #1 CS 106 Intro to Comp. Sci. 1 Wednesday, 12/4/02  Questions?  Return Test #2  General discussion of HW #05  Introduction.
CS 206 Introduction to Computer Science II 09 / 09 / 2009 Instructor: Michael Eckmann.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
Nov 10, Fall 2006IAT 8001 Debugging. Nov 10, Fall 2006IAT 8002 How do I know my program is broken?  Compiler Errors –easy to fix!  Runtime Exceptions.
11-Jun-15 Exceptions. 2 Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 17 Exceptions and.
16-Jun-15 Exceptions. Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null.
Exceptions CIS 304 Intermediate Java Programming for Business.
Exceptions. Errors and Exceptions An error is a bug in your program –dividing by zero –going outside the bounds of an array –trying to use a null reference.
CSSE221: Software Dev. Honors Day 4 Pass in Runtime Assignment now to assistants Pass in Runtime Assignment now to assistants Announcements Announcements.
COMS W1004 Introduction to Computer Science June 3, 2009.
1 Exception Handling (in a nutshell). 2 Motivations When a program runs into a runtime error, the program terminates abnormally. How can you handle the.
Finding and Debugging Errors
CS 280 Data Structures Professor John Peterson. Goals Understand “Programming in the small” Java programming Know what’s under the hood in complex libraries.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 10Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Announcements/Reminders l Project 6 due on Thursday March 31 l Exam.
COMP 14 – 02: Introduction to Programming Andrew Leaver-Fay August 31, 2005 Monday/Wednesday 3-4:15 pm Peabody 217 Friday 3-3:50pm Peabody 217.
Advanced Java Course Exception Handling. Throwables Class Throwable has two subclasses: –Error So bad that you never even think about trying to catch.
Compiling and Linking. Compiling is quite the same as creating an executable file! Instead, creating an executable is a multistage process divided into.
Week 14 - Monday.  What did we talk about last time?  Image manipulation  Inheritance.
CIS 270—Application Development II Chapter 13—Exception Handling.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
Slides Credit Umair Javed LUMS Web Application Development.
Jun 16, 2014IAT 2651 Debugging. Dialectical Materialism  Dialectical materialism is a strand of Marxism, synthesizing Hegel's dialectics, which proposes.
DEBUGGING CHAPTER Topics  Getting Started with Debugging  Types of Bugs –Compile-Time Bugs –Bugs Attaching Scripts –Runtime Errors  Stepping.
1 Project Information and Acceptance Testing Integrating Your Code Final Code Submission Acceptance Testing Other Advice and Reminders.
Questions, Questions, Questions. I like to ask questions. I can ask questions to learn new things.
Introduction to Exception Handling and Defensive Programming.
Program Errors and Debugging Week 10, Thursday Lab.
C++ crash course Class 8 statements, sort, flight times program.
Chapter 12 Using data files. The concept of file Logically cohesive data stored on a permanent storage, such as hard disk (most cases), CD, USB. Types.
CSE 351 GDB Introduction. Lab 1 Status? How is Lab 1 going? I’ll be available at the end of class to answer questions There are office hours later today.
Week 14 - Monday.  What did we talk about last time?  Inheritance.
Conditional Statements.  Quiz  Hand in your jQuery exercises from last lecture  They don't have to be 100% perfect to get full credit  They do have.
Error messages 25-Apr-17.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
CS 177 Week 10 Recitation Slides 1 1 Debugging. Announcements 2 2.
Error Handling Tonga Institute of Higher Education.
How to Improve Your Grades Are your grades rather low? Maybe it's the beginning of school, and your not getting off to a good start. Well, this easy to.
CS116 COMPILER ERRORS George Koutsogiannakis 1. How to work with compiler Errors The Compiler provide error messages to help you debug your code. The.
COP3502 Programming Fundamentals for CIS Majors 1 Instructor: Parisa Rashidi.
CRE Programming Club Class 2 (Import JJZ543 and Practice Your Typing!)
© 2015 albert-learning.com How to talk to your boss How to talk to your boss!!
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Exception. Agenda Exception. Handling Exceptions. The finally Clause.
Introduction to Exceptions in Java CS201, SW Development Methods.
Lecture 5: Exception Handling and Text File I/O Michael Hsu CSULA.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
Testing and Debugging.
Week 14 - Wednesday CS 121.
CS Week 10 Jim Williams, PhD.
Exceptions 10-Nov-18.
Exceptions 10-Nov-18.
Cracking the Coding Interview
Chapter 12 Exception Handling
Exceptions CSCE 121 J. Michael Moore
Web Design & Development Lecture 7
Exceptions 19-Feb-19.
Exceptions 25-Apr-19.
Exceptions 22-Apr-19.
Exceptions 10-May-19.
Exceptions 5-Jul-19.
Software Development Techniques
Presentation transcript:

CS12230 Introduction to Programming Lecture 6-2 –Errors and Exceptions 1

Errors Three kinds: Compiler – missing ; – Don’t recognise a variable or class name Run time – Something happens as you run – Often null pointers Logic – The program runs but not ‘right’ 2

Some run-time errors can be ‘caught’ When reading from a file do you remember ‘throws IOException’ which propagates up the calling sequence? This is sort of like saying that you recognise your code may have a problem Instead, You can ‘catch’ exceptions and deal with them: try{ //piece of code that might cause exception } catch (IOException e) {//or whatever exception //some code to fix problem } 3

Look at the code in 6-week6 BadApplication (next slide) and Application Also summing etc. 4

5

Some run-time errors cannot and should not be caught They should be fixed instead One really common one is ‘NullPointerException’ That means that you are trying to call a method on an object that doesn’t exist For instance, in the code on last slide comment out staff=new ArrayList (); and see what happens 6

How to debug your code Three kinds: Compiler errors – usually not too hard with experience Run time – Try stopping execution just before the error Logic – Run line by line (in debugger or on paper) Show the links on the web site (other resources) 7

At 3pm Go on with adding ArrayLists to the Monsters project 8

Tomorrow I will hand back the test and talk about it at 3pm. Also answer any questions you have on the assignment – make sure you read the 6-3 slides if we don’t do them in class No 10am lecture (so I can finish the marking) 9

Next week is ‘work week’ No CS lectures or Monday lab (demonstrators may be there) tutorials –you may persuade your leader to help you during that slot Yes, Wednesday and Friday practicals This is your big opportunity to get caught up on reading (how many of you have looked at the notes?) and practicals … … and make good start on assignment I may be away for part of it but answering 10