Reviewing for Exam Lecture 12. Lab 1 Postfix.java –Hexadecimal Converting ‘a’ to number Converting ‘1’ to number –System.exit(3); Questions?

Slides:



Advertisements
Similar presentations
Programmer-defined classes Part 2. Topics Returning objects from methods The this keyword Overloading methods Class methods Packaging classes Javadoc.
Advertisements

Lecture 23 Input and output with files –(Sections 2.13, 8.7, 8.8) Exceptions and exception handling –(Chapter 17)
CS102--Object Oriented Programming
Exceptions Don’t Frustrate Your User – Handle Errors KR – CS 1401 Spring 2005 Picture – sysprog.net.
Java I/O Java I/O is based on input streams and output streams. All input and output are defined in the Java IO package. 1.
Class Hierarchy (Inheritance)
Exception Handling 1 CISC6795, Spring Introduction 2 Exception – an indication of a problem that occurs during a program’s execution, for examples:
© The McGraw-Hill Companies, 2006 Chapter 15. © The McGraw-Hill Companies, 2006 Exceptions an exception is an event that occurs during the life of a program.
 2005 Pearson Education, Inc. All rights reserved Exception Handling.
CS 116 OBJECT ORIENTED PROGRAMMING II LECTURE 10 GEORGE KOUTSOGIANNAKIS Copyright: 2014 Illinois Institute of Technology/ George Koutsogiannakis 1.
EXCEPTIONS. What’s an exception?? Change the flow of control when something important happens ideally - we catch errors at compile time doesn’t happen.
Slides prepared by Rose Williams, Binghamton University ICS201 Exception Handling University of Hail College of Computer Science and Engineering Department.
Java Exceptions. Types of exceptions  Checked exceptions: A checked exception is an exception that is typically a user error or a problem that cannot.
Objectives Understanding what an exception is Understanding the heirarchy of exception classes Learn the types of exception and how to catch and handle.
Lecture 28 More on Exceptions COMP1681 / SE15 Introduction to Programming.
1 CS2200 Software Development Lectures 28: Exception Handling A. O’Riordan, 2008 (Includes some slides by Lewis/Loftus 2005 and K. Brown )
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
交通大學資訊工程學系 Programming in Java Exception Handling 蔡文能 交通大學資訊工程學系
Files and Streams CS 21a Chapter 11 of Horstmann.
1 Chapter 2 Introductory Programs. 2 Getting started To create and run a Java program –Create a text file with a.java extension for the source code. For.
Scott Grissom, copyright 2004Ch 3: Java Features Slide 1 Why Java? It is object-oriented provides many ready to use classes platform independent modern.
Misc Language Features Features that were added relatively recently that are now in common use.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Java Exception Handling ● Exception = an event that occurs during the execution of a program that disrupts the normal flow of instructions: – Examples:
Programmer-defined classes Part 3. A class for representing Fractions public class Fraction { private int numerator; private int denominator; public Fraction(int.
Java Exceptions CSc 335 Object-Oriented Programming and Design Spring 2009.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Example 1 :- Handling integer values public class Program1 { public static void main(String [] args) { int value1, value2, sum; value1 = Integer.parseInt(args[0]);
Chapter 12 Inheritance and Exceptions Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas,
CSC172 Intro Pepper. Goals Reminder of what a class is How to create and use classes How to design classes How to think in terms of objects How to comment.
Polymorphism, Inheritance Pt. 1 COMP 401, Fall 2014 Lecture 7 9/9/2014.
CS 2511 Fall  Exception = an event that occurs during the execution of a program that disrupts the normal flow of instructions:  Examples: Out.
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Java I/O Java I/O is based on input streams and output streams. All input and output are defined in the Java IO package. 1.
Object Based Programming Chapter 8. 2 In This Chapter We will learn about classes Garbage Collection Data Abstraction and encapsulation.
Exceptions By the end of this lecture you should be able to: explain the term exception; distinguish between checked and unchecked exception classes in.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
CIS 270—Application Development II Chapter 8—Classes and Objects: A Deeper Look.
Unit 4 School of Information Systems & Technology1 School of Information Systems and Technology (IST)
CPRG 215 Introduction to Object-Oriented Programming with Java Module 4- Exception and Error Handling Topic 4.1 Errors and Exceptions Produced by Harvey.
CSE 143 Lecture 4 More ArrayIntList : Pre/postconditions; exceptions; testing reading: slides created by Marty Stepp and Hélène Martin
Building Java Programs Chapter 15 Lecture 15-2: testing ArrayIntList; pre/post conditions and exceptions reading:
Copyright © Curt Hill Error Handling in Java Throwing and catching exceptions.
Python – May 16 Recap lab Simple string tokenizing Random numbers Tomorrow: –multidimensional array (list of list) –Exceptions.
CSC Java Programming, Fall, 2008 Week 3: Objects, Classes, Strings, Text I/O, September 11.
Inheritance Chapter 11 in Gaddis. Is a relationships in ‘real’ life Exist when one object is a specialized version of another one –Examples An english.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
Java Programming: Exceptions1 Exceptions Reference: java.sun.com/docs/books/tutorial/essential/exceptions/
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
Jozef Goetz Credits: Copyright  Pearson Education, Inc. All rights reserved. expanded by J. Goetz, 2016.
CS 116 Object Oriented Programming II Lecture 4 Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
Exceptions and Error Handling. Exceptions Errors that occur during program execution We should try to ‘gracefully’ deal with the error Not like this.
Winter 2006CISC121 - Prof. McLeod1 Last Time Reviewed class structure: –attributes –methods –(inner classes) Looked at the effects of the modifiers: –public.
Garbage Collection It Is A Way To Destroy The Unused Objects. To do so, we were using free() function in C language and delete() in C++. But, in java it.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
A High Flying Overview CS139 – Fall 2010 How far we have come.
Object Based Programming Chapter 8. 2 Contrast ____________________ Languages –Action oriented –Concentrate on writing ________________ –Data supports.
Lecture 7 D&D Chapter 7 & 8 Composite Classes and enums Date.
OBJECT ORIENTED PROGRAMMING II LECTURE 10 GEORGE KOUTSOGIANNAKIS
Testing and Debugging.
CS Week 10 Jim Williams, PhD.
Reviewing for Exam Lecture 1?.
Object Based Programming
E x c e p t i o n s Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. — Martin Golding.
Implementing Non-Static Features
More On Enumeration Types
Web Design & Development Lecture 7
Additional information re files
Chapter 12 Exception Handling and Text IO Part 1
Presentation transcript:

Reviewing for Exam Lecture 12

Lab 1 Postfix.java –Hexadecimal Converting ‘a’ to number Converting ‘1’ to number –System.exit(3); Questions?

Lecture 1 Test cases for programs Documentation –Echo of input –Inline comments –Ending message –Javadocs

Lab 2 PseudoWar game –Test cases –Stubs –Program Required –Constructors –Specific methods –Generation of number in range 1 to 52

Lab 3 Exception –Handlers Try Catch –printStackTrace() –getMessage() –Multiple handlers –Avoiding

Lecture 3 Style guidelines Chapter12 slides

Lab 4 Writing code from scratch –Illustrating use of exception handlers –Illustrating avoidance of exceptions –Java Tutorial –Java api

ArithmeticException ArrayIndexOutOfBoundsException FileNotFoundException PatternSyntaxException ClassNotFoundException InputMisMatchException NullPointerException NumberFormatException StringIndexOutOfBoundsException NegativeArraySizeException ArrayStoreException MalformedURLException IOException IllegalArgumentException ClassCastExceptionIllegal FormatConversionException

Lecture 4 Common Exceptions –That can be avoided –That can not be avoided Reading from Files Compile time errors Runtime errors

Lab 5 File I/O –PrintWriter (flush) –File –java.io package Use of command line arguments Use of re-direct symbols

Lecture 5 Play with text examples –Use of StringTokenizer –Use of delimiters –Use of regular expressions Correct use of Boolean in if and while statements How comments help

Lab 6 Enumerated types Enhanced for loop (i.e. for… each)

Lecture 6 public enum Sessions { SPRING, SUMMER, FALL ; }

public enum Planet { MERCURY (3.303e+23, e6), VENUS (4.869e+24, e6), EARTH (5.976e+24, e6), MARS (6.421e+23, e6), JUPITER (1.9e+27, e7), SATURN (5.688e+26, e7), URANUS (8.686e+25, e7), NEPTUNE (1.024e+26, e7); … for (Planet p : Planet.values()) System.out.printf ("Your weight on %s is %f%n", p, p.surfaceWeight(mass));

Lab 7 Enumerated types again –Rank –Suit –Card –Deck (?) Order Valid elements Attributes

for (Rank r : Rank.values()) { System.out.println ( r + " " + r.getBridgePoints() + " " + r.getAbbreviation() ); } // end for Example for-each

Lecture 7 Chapter 9 – Chapter_9_Part1.ppt slides ClearJunk.java

Lab 8 Classes –toString methods –equals methods when needed how used –static fields

Lecture 8 A few things Chapter 9 – rest of slides

Lab 9 UML diagram Die objects –getFaceValue –setFaceValue –toString –Roll –Math.random vs Random

Lecture 9 Talk about constructors – belongs to class –do not have a visibility modifier –same name as class –may have no parameters (no-arg constructor) –may have one or more parameters (explicit value constructor) –class may have no explicit constructor –class may have more than one constructor –doesn't return values

Lab 10 Code re-use Array of objects Explicit value constructors No-arg constructors Reading carefully

Lecture 10 Professor Harris lecture – see blackboard

Lab 11 Designing classes DISCUSSION –Getters and setters are, in general, public methods. Since Fraction is immutable, shouldn’t have them. –Fraction is 4/20 not.20 –Numerator and denominator are ints

Lecture 11 Somewhat of a repetition of lecture 10

Lab 12 Inheritance –Employee SalariedWorker HourlyWorker

Lecture 12 Review

Lab 13 Specialization and Inheritance DISCUSSION –Needed to look at javadocs –Can’t compare one ampm to another using == because they are Strings – need.equals –An AlarmClock is-a Clock (a Clock is NOT an AlarmClock).