Published in 1976, this book was one of the most influential computer science books of the time, and was used extensively in education.

Similar documents
Published in 1976, this book was one of the most influential computer science books of the time, and was used extensively in education.

c) And last but not least, there are javadoc comments. See Weiss.

Assertions, pre/postconditions

Introduction to Programming Using Java (98-388)

boolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while

Chapter 6 Introduction to Defining Classes

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

Chapter 4 Defining Classes I

F1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept

Object-Oriented Programming

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

Classes and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון

Java: Classes. An instance of a class is an object based on the class. Creation of an instance from a class is called instantiation.

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Classes and Methods גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון

Use the scantron sheet to enter the answer to questions (pages 1-6)

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.


Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Type Hierarchy. Comp-303 : Programming Techniques Lecture 9. Alexandre Denault Computer Science McGill University Winter 2004

Java SE 8 Programmer I and II Syballus( Paper codes : 1z0-808 & 1z0-809)

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

CSE 331 Summer 2017 Final Exam. The exam is closed book and closed electronics. One page of notes is allowed.

Properties of an identifier (and the object it represents) may be set at

1 Shyam sir JAVA Notes

CONSTRUCTOR & Description. String() This initializes a newly created String object so that it represents an empty character sequence.

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

DEPARTMENT OF INFORMATION TECHNOLOGY

Arrays Classes & Methods, Inheritance

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).

WA1278 Introduction to Java Using Eclipse

Java SE 8 Programming

Class, Variable, Constructor, Object, Method Questions

Object Orientation Fourth Story. Bok, Jong Soon

Chapter 3:: Names, Scopes, and Bindings (cont.)

Chapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures

15CS45 : OBJECT ORIENTED CONCEPTS

Chapter 3:: Names, Scopes, and Bindings (cont.)

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Classes and Methods עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון מבוסס על השקפים של אותו קורס שניתן בשנים הקודמות

Lecture 7: Data Abstractions

CO Java SE 8: Fundamentals

1 A question of semantics

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline ::

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

Programming overview

Inheritance (Part 5) Odds and ends

Java Object Oriented Design. CSC207 Fall 2014

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

JAVA MOCK TEST JAVA MOCK TEST II

Java SE 8 Programming

VALLIAMMAI ENGINEERING COLLEGE

Java Classes: Math, Integer A C S L E C T U R E 8

Compaq Interview Questions And Answers

What about Object-Oriented Languages?

Discover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs.

Chapter 14 Abstract Classes and Interfaces

Inheritance. Transitivity

Subclassing for ADTs Implementation

Java: advanced object-oriented features

52 Franck van Breugel and Hamzeh Roumani

Pages and 68 in [JN] conventions for using exceptions in Java. Chapter 8 in [EJ] guidelines for more effective use of exceptions.

Java classes cannot extend multiple superclasses (unlike Python) but classes can implement multiple interfaces.

University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner

Operators and Expressions

Java SE 8 Programming

Java Fundamentals (II)

Review sheet for Final Exam (List of objectives for this course)

JAVA CONCEPTS Early Objects

PIC 20A The Basics of Java

CS 101 Exam 1 Spring 200 Id Name

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects

Java Application Development

Class object initialization block destructor Class object

Chapter 10 Classes Continued. Fundamentals of Java

EECS168 Exam 3 Review

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Objective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5

CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017

CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II

EINDHOVEN UNIVERSITY OF TECHNOLOGY

7. C++ Class and Object

Lecture Notes on Contracts

Building Java Programs

After a lecture on cosmology and the structure of the solar system, William James was accosted by a little old lady.

COMP 250 Fall inheritance Nov. 17, 2017

CE221 Programming in C++ Part 1 Introduction

Chapter 4: Writing Classes

CS 251 Intermediate Programming Inheritance

Object-Based Programming. Programming with Objects


CSE331 Winter 2014, Midterm Examination February 12, 2014

Using APIs. Chapter 3. Outline Fields Overall Layout. Java By Abstraction Chapter 3. Field Summary static double PI

Transcription:

Published in 1976, this book was one of the most influential computer science books of the time, and was used extensively in education.

Niklaus Emil Wirth (1934 ) Ph.D 1963 from Berkeley in Electrical Engineering A generalization of ALGOL, Professor of Computer Science at ETH Zurich from 1968 until he retired in 1999. In 1984 he received the ACM Turing Award and in 1987 the Computer Pioneer award from the IEEE. Algol committee, ALGOL W, Pascal, Euclid, Modula, Oberon.

1984 Turing Award Niklaus Emil Wirth (1934 ) For developing a sequence of innovative computer languages, EULER, ALGOL-W, MODULA and Pascal

Trilingual Pun: Pascal/English/German When asked how to pronounce his name, he is said to have answered that if you call him by name, it is virt (the German pronunciation), and if you call him by value, it is worth (the American pronunciation). ( Wert in German means value. )

Wirth s Law Wirth s Law asserts that software execution is slowing down faster than hardware is speeding up. Groves giveth, and Gates taketh away. That is, as the speed of calculation rises, thanks to Intel s Andy Grove, the amount of calculation needed to do the job rises also, thanks to Microsoft s Bill Gates, leaving hardly any gains for the user to enjoy. Some assume that the ignorant or tolerant user is responsible. ETH Zurich s Niklaus Wirth, who actually credits the law to former IBM Research scientist Martin Reiser, claims that software companies pressure to roll out new products, not user tolerance, is chiefly responsible for feature bloat. Wirth s article crediting Reiser, A Plea for Lean Software, appeared in IEEE Computer, February 1995, volume 28, number 2.

Procedural Abstraction Data Abstraction

Classes Java is an object-oriented language. It is impossible to give a simple explanation for what that means. Java is organized around a construct known as a class. What is a class? It is the most prominent feature of the Java language for incorporating all program parts, for creating instances of data structures, and for the design of other classes.

The three I s There are three goals disparate goals for which a Java class can be used. 1. incorporation (cue static) 2. instantiation (cue new) 3. inheritance (cue extends)

Classes I The class in Java is fundamental unit of program construction. And it has syntax: class ClassName { // Contents of class : // static fields // static methods // static inner classes // static initializer blocks } The class is the principle unit of compilation. These members of the class are said to be static, class, or class-wide members.

Classes II A Java class is (also) a template for creating new instances called objects. class ClassName { // Instance fields // Constructors // Instance methods } These members of the class are said to be instance members. Instances are constructed using the keyword new followed by the name of the class. Arguments are permitted in construction, provided an appropriate constructor has been defined. Two types: data structures and simulation objects

Classes III Java classes can be used to derive other classes. This permits data structures to be organized to take advantage of their commonality (if any). Cues: the keyword extends and the related keyword implements. class ClassName extends SuperClass { // Changes and additions to the super class // additional member fields and methods }

Syntax A class declaration may be prefixed by a number of modifiers (some meaningful only for inner classes): public protected private abstract static final strictfp class modifiers local incomplete, uninstantiable independent all methods final, no subclasses all methods, operations FP-strict

Incorporation Some examples of incorporation from the Java API: For example, the math functions class Math { static double PI static int abs () static double sqrt () static double atan () static double pow () } For example, the standard I/O package: class System { static InputStream in static OutputStream out static OutputStream err } Classes include facilities; your cue is the keyword static.

Incorporation Other examples: class Arrays { static void sort () static String tostring () } class Integer { static int parseint () static String tostring () } Note: wrapper classes are used as templates for data, as well. Also: class MyClass { static final int PARAMETER //... static memb public static void main //... point of en }

Incorporation How are these facilities accessed? class name. static member name double pi = Math. PI; double x = Math. sqrt (3.14159); Arrays. sort ( new int [] {4,2,8,1,9,2,7,6,5,8}); int i = Integer. parseint ("3"); String s = Integer. tostring (3, 8);

Classes are sometimes used for incorporation (though sometimes all uses are mixed together). incorporation/junk.java incorporation/main.java incorporation/supervisor.java misc/init.java (static initialization blocks)

II: Instantiation

Instantiation A class as a template stamps out new data. Each instance has its own data as opposed to shared (static) data and as opposed to local data in a method.

Data Structures Data structure. A data structure is a way of organizing and accessing data. We have seen integers, strings, streams, scanners, arrays, lists, and so on. It is important to distinguish between the data structure (the organization), and the particular data (the instance). In Java, the class is used as a model or a template for organizing data, and an instance of a template is obtained using the keyword new. Instances of classes are also called objects. misc/main.java (object creation and method invocation) How are these facilities accessed? class instance. instance member name String line = stdin. nextline (); int length = " abc ". length ();

Using class instances. misc/main.java io/copytext.java string/stringfest.java

Diversion to lexicographic order? Section 3.1 of textbook??

Class as Data Structure public class SimpleTime { int hours ; int minutes ; } One top-level class per file or compilation complications.

basic/simpletime1.java and basic/timemain.java basic/simpletime2.java basic/simpletime3.java basic/simpletime4.java basic/simpletime5.java basic/simpletime6.java van der Linden, Chapter 2: The Story of O.

Simple, complete classes as data structures. basic/point2d.java class/circle.java class/line.java class/polynomial.java [Arrays need private access.] class/person.java [Mutable objects need private access], class/person8.java class/elephant.java [Private constructors are useful.]

constructors constructor chaining blank-finals immutable classes singleton pattern (factory methods) [discussed with collators in lexicographic ordering] classes can be nested (use keyword static)

In addition to classes for immutable data structures, classes are used to create objects of simulation. The data structures have state that changes during the lifetime of the object.

Class as Simulation draw/image.java class/bankaccount.java. assert statement, preconditions, postconditions simulation/aircraft.java

A precondition is a requirement that the caller of a method must meet. If a method is called in violation of a precondition, the method is not responsible for computing the correct result. Horstman, page 293. A precondition is an assertion that is guaranteed to be true after a method is called. A class invariant is an assertion true when a class is constructed and after all methods.

[Go to other next PDF: objects]