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.

Assertions, pre/postconditions

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

Chapter 6 Introduction to Defining Classes

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

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

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

Chapter 4 Defining Classes I

Object-Oriented Programming

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

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

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.

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

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


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

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

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

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

1 Shyam sir JAVA Notes

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

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

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.

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

Arrays Classes & Methods, Inheritance

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

Java SE 8 Programming

Class, Variable, Constructor, Object, Method Questions

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

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

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

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

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

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

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

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

1 A question of semantics

CO Java SE 8: Fundamentals

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

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 Object Oriented Design. CSC207 Fall 2014

Java SE 8 Programming

Inheritance. Transitivity

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

What about Object-Oriented Languages?

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

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

Chapter 14 Abstract Classes and Interfaces

JAVA CONCEPTS Early Objects

Subclassing for ADTs Implementation

WA1278 Introduction to Java Using Eclipse

Java SE 8 Programming

52 Franck van Breugel and Hamzeh Roumani

DEPARTMENT OF INFORMATION TECHNOLOGY

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

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

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

Java Application Development

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

Chapter 10 Classes Continued. Fundamentals of Java

EINDHOVEN UNIVERSITY OF TECHNOLOGY

Lecture Notes on Contracts

Object Orientation Fourth Story. Bok, Jong Soon

Class object initialization block destructor Class object

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

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

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

VALLIAMMAI ENGINEERING COLLEGE


COMP 250 Fall inheritance Nov. 17, 2017

Object-Based Programming. Programming with Objects

2/3/2018 CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II. Lecture Contents. C# basics. Methods Arrays. Dr. Amal Khalifa, Spr17

CS 251 Intermediate Programming Inheritance

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

Chapter 4: Writing Classes

The return Statement

Instance Members and Static Members

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Programming overview

CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013

Lecture 7: Data Abstractions

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods.

Get Unique study materials from

ΠΙΝΑΚΑΣ ΠΛΑΝΟΥ ΕΚΠΑΙΔΕΥΣΗΣ

Operators and Expressions

Inheritance (Part 5) Odds and ends

Java: advanced object-oriented features

IBS Software Services Technical Interview Questions. Q1. What is the difference between declaration and definition?

Rules and syntax for inheritance. The boring stuff

SQL. Dean Williamson, Ph.D. Assistant Vice President Institutional Research, Effectiveness, Analysis & Accreditation Prairie View A&M University

Lecture 18 Tao Wang 1

1001ICT Introduction To Programming Lecture Notes

PIC 20A The Basics of Java

Compaq Interview Questions And Answers

More About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario

Exam Duration: 2hrs and 30min Software Design

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 worth. )

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 initializer blocks // static inner classes } 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 begins with the word class: < class declaration > ::= " class " < identifier > "{" <class body > "}" < class body > ::= { < class body declaration > } < class body declaration > ::= ";" " static " < statement block > { < modifier > } < member declaration > < member declaration > ::= < field declaration > < method declaration > < constructor declaration > < interface declaration > < class declaration > Note that classes can be nested and that they may contain static initialization blocks.

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 incomplete, uninstantiable all methods final, no subclasses all methods, operations FP-strict

Syntax < class declaration > ::= " class " < identifier > [ < type parameter list >] [" extends " <type >] [" implements " <type list >] "{" <class body > "}"

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 class Arrays { static void sort () static String tostring () } class Integer { static int parseint () static String tostring () } For example, 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 more often all uses are mixed together). incorporation/junk.java incorporation/main.java incorporation/supervisor.java misc/init.java (static initialization blocks)

Intantiation 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

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 van der Linden, Chapter 2: The Story of O.

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]