1.7 Errors Compile-time error: A violation of the programming language rules that is detected by the compiler Example: System.ou.println("Hello, World!);

Slides:



Advertisements
Similar presentations
Chapter 5 Errors Bjarne Stroustrup
Advertisements

Chapter 1: Introduction
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter Three - Implementing Classes.
Chapter 9 – Inheritance Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved.
Chapter 1 These slides for CSE 110 Sections are based in part on the textbook-authors’ slides, which are copyright by the authors. The authors state that.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Chapter 1 Introduction. Goal to learn about computers and programming to compile and run your first Java program to recognize compile-time and run-time.
Programming Lifecycle
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction.
ICOM 4015: Advanced Programming Lecture 1 Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Reading: Chapter One: Introduction.
When constructing a two-dimensional array, specify how many rows and columns are needed: final int ROWS = 3; final int COLUMNS = 3; String[][] board =
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction ( ปรับปรุง )
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Chapter 1 - Introduction.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
How to Program? -- Part 1 Part 1: Problem Solving –Analyze a problem –Decide what steps need to be taken to solve it. –Take into consideration any special.
ERRORS. Types of errors: Syntax errors Logical errors.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Array length = maximum number of elements in array Usually, array is partially filled Need companion variable to keep track of current size Uniform naming.
5.01 Understand Different Types of Programming Errors
Chapter 7 – Arrays and Array Lists Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. 1.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. A string is a sequence of characters Strings are objects of the String.
Slides by Evan Gallagher
Slides by Evan Gallagher
Chapter 1 – Introduction
Why don’t programmers have to program in machine code?
Department of Computer Science,
A final variable is a constant
Dept of Computer Science University of Maryland College Park
Introduction To recognize compile-time and run-time errors
5.01 Understand Different Types of Programming Errors
John Woodward A Simple Program – Hello world
Lecture 3 John Woodward.
Chapter 4 – Fundamental Data Types
Chapter Goals To learn about computers and programming
Software Design and Development
Chapter 1 – Introduction
Slides by Donald W. Smith
Chapter Three - Implementing Classes
5.01 Understand Different Types of Programming Errors
Designing and Debugging Batch and Interactive COBOL Programs
Chapter 2 – Getting Started
Building Java Programs Chapter 2
Chapter 15 Debugging.
Unit 1: Introduction Lesson 1: PArts of a java program
An Introduction to Structured Program Design in COBOL
Copyright © 2014 John Wiley & Sons, Inc. All rights reserved.
Algorithm Correctness
Chapter 15 Debugging.
Wednesday 09/23/13.
Bugs & Debugging - Testing
Page 535 Advanced Engineering Mathematics by Erwin Kreyszig
An Introduction to Debugging
Learning Intention I will learn about the different types of programming errors.
Use a variable to store a value that you want to use at a later time
4.3 Arithmetic Operators and Mathematical Functions
Chapter 5 – Decisions Big Java by Cay Horstmann
Each object belongs to a class
6.2 for Loops Example: for ( int i = 1; i
Parameter: an input to a method
Copyright © 2014 John Wiley & Sons, Inc. All rights reserved. Chapter 20 Managing the Multinational Financial System Tenth Edition Alan C. Shapiro Multinational.
Presentation transcript:

1.7 Errors Compile-time error: A violation of the programming language rules that is detected by the compiler Example: System.ou.println("Hello, World!); Syntax error Run-time error: Causes the program to take an action that the programmer did not intend Examples: System.out.println("Hello, Word!"); System.out.println(1/0); Logic error Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved.

Error Management Strategy Learn about common errors and how to avoid them Use defensive programming strategies to minimize the likelihood and impact of errors Apply testing and debugging strategies to flush out those errors that remain Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved.

Self Check 1.15 Suppose you omit the // characters from the HelloPrinter.java program but not the remainder of the comment. Will you get a compile-time error or a run-time error? Answer: A compile-time error. The compiler will not know what to do with the word Display. Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved.

Self Check 1.16 When you used your computer, you may have experienced a program that “crashed” (quit spontaneously) or “hung” (failed to respond to your input). Is that behavior a compile-time error or a run-time error? Answer: It is a run-time error. After all, the program had been compiled in order for you to run it. Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved.

Self Check 1.17 Why can't you test a program for run-time errors when it has compiler errors? Answer: When a program has compiler errors, no class file is produced, and there is nothing to run. Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved.