Chapter 9: High Level Language
|
|
- Abraham Hudson
- 6 years ago
- Views:
Transcription
1 Elements of Computing Systems, Nisan & Schocken, MIT Press, Chapter 9: High Level Language Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This presentation contains lecture materials that accompany the textbook The Elements of Computing Systems by Noam Nisan & Shimon Schocken, MIT Press, The book web site, features 13 such presentations, one for each book chapter. Each presentation is designed to support about 3 hours of classroom or self-study instruction. You are welcome to use or edit this presentation for instructional and non-commercial purposes. If you use our materials, we will appreciate it if you will include in them a reference to the book s web site. And, if you have any comments, you can reach us at tecs.ta@gmail.com Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 1
2 Where we are at: Human Thought Abstract design Chapters 9, 12 abstract interface H.L. Language & Operating Sys. Compiler Chapters abstract interface Virtual Machine Software hierarchy VM Translator Chapters 7-8 abstract interface Assembly Language Assembler Chapter 6 abstract interface Machine Language Computer Architecture Chapters 4-5 Hardware hierarchy abstract interface Hardware Platform Gate Logic Chapters 1-3 abstract interface Chips & Logic Gates Electrical Engineering Physics Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 2
3 Brief history of programming languages (some milestones) Machine language Assembler: symbolic programming Fortran: formula translation Algol: structured programming, dynamic memory Pascal, C: industrial strength compilers C++: OO Java, C#: OO done well Other paradigms. Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 3
4 The OO approach to programming Object = entity associated with properties (fields) and operations (methods) Objects are instances of classes E.g. bank account, employee, transaction, window, gamesession, OO programming: identifying, designing and implementing classes Each class is typically: A template for generating and manipulating objects and/or A collection of related subroutines. Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 4
5 An OO programming language can be used for Procedural programming Abstract data types Concrete objects Abstract objects Graphical objects Software libraries And more. Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 5
6 Jack: a typical OO language -- sample applications Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 6
7 Disclaimer Although Jack is a real programming language, we don t view it as an end Rather, we view Jack as a means through which we explain: How to build a compiler How the compiler and the language interface with an OS How the topmost piece in the software hierarchy fits into the picture Jack s most important virtue: it can be learned (and un-learned) it in 1 hour. Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 7
8 Example 0: hello world /** /** Hello Hello World World program. program. */ */ class class Main Main { void void main() main() { /* /* Prints Prints some some text text using using the the standard standard library. library. */ */ do do Output.printString( Hello World ); World ); do do Output.println(); // // New New line line return; return; Java-like syntax Comments Standard library. Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 8
9 Example 1: procedural programming class class Main Main { /* /* Sums Sums up up n */ */ int int sum(int sum(int n) n) { var var int int i, i, sum; sum; let let sum sum = 0; 0; let let i = 1; 1; while while (~(i>n)) (~(i>n)) { let let sum sum = sum sum + i; i; let let i = i + 1; 1; return return sum; sum; void void main() main() { var var int int n, n, x; x; let let n = Keyboard.readInt( Enter n: n: ); ); let let x = Main.sum(n); do do Output.printString("The result result is: is: "); "); do do Output.printInt(sum); do do Output.println(); return; return; // // Main Main Jack program = collection of one or more classes Jack class = collection of one or more subroutines Jack subroutine: Function Method Constructor (the example on the left has s only, as it is object-less ) There must be one Main class, and one of its methods must be main. Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 9
10 Example 2: OO programming class class BankAccount { static static int int naccounts; // // account account properties field field int int id; id; field field String String owner; owner; field field int int balance; balance; /* /* Constructs a new new bank bank account. account. */ */ constructor BankAccount new(string aowner) aowner) { let let id id = naccounts; let let naccounts = naccounts + 1; 1; let let owner owner = aowner; aowner; let let balance balance = 0; 0; return return this; this; var // // More More BankAccount methods. var int int sum; sum; methods. var var BankAccount b, b, c; c; // // BankAccount let let b=bankaccount.new( Joe ); Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 10
11 Example 2: typical OO programming (cont.) class class BankAccount { static static int int naccounts; // // account account properties field field int int id; id; field field String String owner; owner; field field int int balance; balance; // // Constructor (omitted) /* /* Deposits Deposits money money in in this this account. account. */ */ method method void void deposit(int amount) amount) { let let balance balance = balance balance + amount; amount; return; return; /* /* Withdraws money money from from this this account. account. */ */ method method void void withdraw(int amount){ amount){ if if (balance (balance > amount) amount) { let let balance balance = balance balance - amount; amount; return; return; // // More More BankAccount methods. methods. // // BankAccount var var int int sum; sum; var var BankAccount b, b, c; c; let let b=bankaccount.new( Joe ); do do b.deposit(5000); let let c=bankaccount.new( jane ); let let sum sum = 1000; 1000; do do b.withdraw(sum); Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 11
12 Example 2: typical OO programming (cont.) class class BankAccount { static static int int naccounts; // // account account properties field field int int id; id; field field String String owner; owner; field field int int balance; balance; // // Constructor (omitted) /* /* Prints Prints information about about this this account. account. */ */ method method void void printinfo() { do do Output.printInt(ID); do do Output.printString(owner); do do Output.printInt(balance); return; return; /* /* Destroys Destroys this this account. account. */ */ method method void void dispose() { do do Memory.deAlloc(this); return; return; // // More More BankAccount methods. methods. // // BankAccount var var int int sum; sum; var var BankAccount b, b, c; c; // // Construct and and manipulate // // b and and c do do b.printinfo(); do do b.dispose(); Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 12
13 Example 3: abstract data types (API + usage) Motivation: Jack has only 3 primitive data type: int, char, boolean Fraction API Using the Fraction API (example) API = public contract Interface / implementation. Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 13
14 Example 3: abstract data types (implementation) Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 14
15 Example 3: abstract data types (implementation cont.) Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 15
16 Example 4: linked list /** /** Provides Provides a linked linked list list abstraction. */ */ class class List List { field field int int data; data; field field List List next; next; /* /* Creates Creates a new new List List object. object. */ */ constructor List List new(int new(int car, car, List List cdr) cdr) { let let data data = car; car; let let next next = cdr; cdr; return return this; this; /* /* Disposes Disposes this this List List by by recursively disposing its its tail. tail. */ */ method method void void dispose() { if if (~(next (~(next = null)) null)) { do do next.dispose(); class do do Memory.deAlloc(this); class Foo Foo {... return;... return; // // Creates Creates a list list holding holding the the numbers numbers (2,3,5). (2,3,5).... void void create235() {... var // // class class List. var List List v; v; List. let let v = List.new(5,null); let let v = List.new(2,List.new(3,v)); Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 16
17 Jack language specification Syntax Data types Variable kinds Expressions Statements Subroutine calling Program structure Standard library (for complete coverage, see chapter 9 in the book). Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 17
18 Jack syntax Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 18
19 Jack syntax (cont.) Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 19
20 Jack data types Primitive: Int 16-bit 2 s complement (15, -2, 3,...) Boolean 0 and 1, standing for true and false Char unicode character ( a, x, +, %,...) Abstract data types (supplied by the OS or by the user): String Fraction List... Application-specific objects: BankAccount Bat / Ball... Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 20
21 Jack data types: memory allocation Object types are represented by a class name and implemented as a reference, i.e. a memory address Memory allocation: Primitive variables are allocated memory space when they are declared Object variables are allocated memory space when they are created via a constructor. Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 21
22 Jack variable kinds and scope Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 22
23 Jack expressions No operator priority! Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 23
24 Jack Statements let letvariable = expression; or or let let variable variable [expression] = expression; if if (expression){ statements else else { statements while (expression){ statements do do -or-method-call; return expression; or or return; Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 24
25 Jack subroutine calls general syntax: subroutinename(arg1, arg2, ) Each argument is a valid Jack expression Parameter passing is by value Example: suppose we have int sqrt(int n) This can be invoked as follows: sqrt(17) sqrt(x) sqrt(a*c-17) sqrt(a*sqrt(c-17)+3) Etc. Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 25
26 Jack subroutine calls (cont.) Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 26
27 Jack program structure Each class in a separate file (compilation unit) Jack program = collection of classes, containing a Main.main() Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 27
28 Jack standard library = language extensions = OS class class Math Math { void void init() init() Class Class String String int int abs(int { abs(int x) x) constructor int int multiply(int String String new(int new(int x, x, int maxlength) int y) y) method Class method Class Array int void Array { int void divide(int dispose() x, x, int int y) y) method method int int int int min(int length() min(int Array Array length() x, x, new(int new(int y) y) size) method class size) method class int char Output int char Output max(int charat(int { max(int x, x, int y) j) y) j) method method method method int void int void void sqrt(int void setcharat(int dispose() void sqrt(int void movecursor(int x) j, x) j, char char c) i, c) i, int int j) j) method method String Class String Class Screen Screen appendchar(char void void printchar(char { c) c) c) c) method method void void eraselastchar() void void void void printstring(string clearscreen() s) s) method method int class int class Memory Memory intvalue() void void void void printint(int setcolor(boolean { i) b) i) b) method method void void setint(int void void void void println() drawpixel(int x, x, int int y) j) peek(int peek(int address) y) j) Class address) Class char char backspace() void void Keyboard void void Keyboard backspace() drawline(int { x1, x1, int int y1, y1, void void poke(int poke(int x2, address, x2, address, int int y2) y2) int int value) value) char char doublequote() char void void drawrectangle(int char keypressed() Class x1, x1, int int y1, y1, char char newline() Class Sys int Array Sys { Array alloc(int size) int size) x2, x2, int int y2) char char readchar() y2) void void drawcircle(int x, x, int int y, y, int int r) void r) void void dealloc(array void halt(): halt(): o) o) String String readline(string message) message) void void error(int errorcode) int int readint(string message) message) void void wait(int wait(int duration) Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 28
29 Perspective Jack is an object-based language: no inheritance Primitive type system Standard library Our hidden agenda: gearing up to understand how to develop a: Compiler (chapters 10-11) OS (chapter 12). Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 9: High Level Language slide 29
High Level Language (Jack)
IWKS 3300: NAND to Tetris Spring 2018 John K. Bennett High Level Language (Jack) Foundations of Global Networked Computing: Building a Modern Computer From First Principles This course is based upon the
More informationHigh-Level Language. Where we are at: Some milestones in the evolution of programming languages. Programming languages
Where we are at: High-Level Language Human Thought Abstract design Chapters 9, 12 H.L. Language & Operating Sys. Compiler Chapters 10-11 Virtual Machine Software hierarchy VM Translator Chapters 7-8 Assembly
More informationHigh-Level Language. Building a Modern Computer From First Principles.
High-Level Language Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 9: High-Level Language
More informationHigh-Level Language. Where we are at:
Where we are at: High-Level Language Human Thought Abstract design Chapters 9, 12 abstract interface H.L. Language & Operating Sys. Compiler Chapters 10-11 abstract interface Virtual Machine Software hierarchy
More informationChapter 11: Compiler II: Code Generation
Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005 Chapter 11: Compiler II: Code Generation www.idc.ac.il/tecs Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This
More informationChapter 8: Virtual Machine II: Program Control
Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005 Chapter 8: Virtual Machine II: Program Control www.idc.ac.il/tecs Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken
More informationIntroduction: Hello, World Below
Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005 www.idc.ac.il/tecs Introduction: Hello, World Below Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This presentation
More informationChapter 6: Assembler
Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005 www.idc.ac.il/tecs Chapter 6: Assembler Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This presentation contains
More information12. The Operating System 1
Chapter 12: The Operating System 1 12. The Operating System 1 Civilization progresses by extending the number of operations that we can perform without thinking about them" (Alfred North Whitehead, Introduction
More informationChapter 10: Compiler I: Syntax Analysis
Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005 Chapter 10: Compiler I: Syntax Analysis www.idc.ac.il/tecs Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This
More informationCompiler I: Sytnax Analysis
Elements of Computing Systems, Nisan & Schocken, MIT Press www.idc.ac.il/tecs Compiler I: Sytnax Analysis Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This presentation contains
More informationCompiler II: Code Generation Human Thought
Course map Compiler II: Code Generation Human Thought Abstract design Chapters 9, 12 abstract interface H.L. Language & Operating Sys. Compiler Chapters 1-11 abstract interface Virtual Machine Software
More informationVirtual Machine. Part II: Program Control. Building a Modern Computer From First Principles.
Virtual Machine Part II: Program Control Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 8:
More informationVirtual Machine Where we are at: Part I: Stack Arithmetic. Motivation. Compilation models. direct compilation:... 2-tier compilation:
Where we are at: Virtual Machine Part I: Stack Arithmetic Human Thought Abstract design Chapters 9, 12 H.L. Language & Operating Sys. Compiler Chapters 10-11 Virtual Machine Software hierarchy Translator
More informationVirtual Machine. Part I: Stack Arithmetic. Building a Modern Computer From First Principles.
Virtual Machine Part I: Stack Arithmetic Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 7:
More information10. The Compiler II: Code Generation 1
Chapter 10: The Compiler II: Code Generation 1 10. The Compiler II: Code Generation 1 This document describes the usage and input syntax of the Unix Vax-11 assembler As. As is designed for assembling code
More informationIntroduction: From Nand to Tetris
Introduction: From Nand to Tetris Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Introduction slide
More informationMotivation. Compiler. Our ultimate goal: Hack code. Jack code (example) Translate high-level programs into executable code. return; } } return
Motivation Jack code (example) class class Main Main { { static static int int x; x; function function void void main() main() { { Inputs Inputs and and multiplies multiplies two two numbers numbers var
More informationVirtual Machine (Part II)
Harvard University CS 101 Fall 2005, Shimon Schocken Virtual Machine (Part II) Elements of Computing Systems 1 Virtual Machine II (Ch. 8) Where we are at: Human Thought Abstract design Chapters 9, 12 H.L.
More informationAssembler Human Thought
Where we are at: Assembler Human Thought Abstract design Chapters 9, 12 H.L. Language & Operating Sys. Compiler Chapters 10-11 Virtual Machine Software hierarchy VM Translator Chapters 7-8 Assembly Language
More informationAssembler. Building a Modern Computer From First Principles.
Assembler Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 6: Assembler slide 1 Where we are
More informationCompiler I: Syntax Analysis
Compiler I: Syntax Analysis Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 10: Compiler I:
More informationCourse overview. Introduction to Computer Yung-Yu Chuang. with slides by Nisan & Schocken (www.nand2tetris.org)
Course overview Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken (www.nand2tetris.org) Logistics Meeting time: 2:20pm-5:20pm, Tuesday Classroom: CSIE Room 104 Instructor: 莊永裕 Yung-Yu
More informationCourse overview. Introduction to Computer Yung-Yu Chuang. with slides by Nisan & Schocken (
Course overview Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken (www.nand2tetris.org) Logistics Meeting time: 2:20pm-5:20pm, Tuesday Instructor: 莊永裕 Yung-Yu Chuang Webpage: http://www.csie.ntu.edu.tw/~cyy/introcs
More informationCourse overview. Introduction to Computer Yung-Yu Chuang. with slides by Nisan & Schocken (
Course overview Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken (www.nand2tetris.org) Logistics Meeting time: 2:20pm-5:20pm, Tuesday Classroom: CSIE Room 101 Instructor: 莊永裕 Yung-Yu
More information1st Semester MTCE 601A COMPUTER SYSTEM SOFTWARE
1st Semester MTCE 601A COMPUTER SYSTEM SOFTWARE LECTURE-1 Syllabus Introduction 1.1 Introduction to Object Oriented 1.2 Introduction to UML 1.3 Software Process and OOA&D 1.4 Component and CBSD 1.5 Patterns
More informationElements of Computing Systems, Nisan & Schocken, MIT Press. Boolean Arithmetic
Elements of Computing Systems, Nisan & Schocken, MIT Press www.idc.ac.il/tecs Boolean Arithmetic Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This presentation contains lecture
More informationSoftware Design and Analysis for Engineers
Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 2 Date:
More informationObject-Oriented Programming Paradigm
Object-Oriented Programming Paradigm Sample Courseware Object-Oriented Programming Paradigm Object-oriented programming approach allows programmers to write computer programs by representing elements of
More informationCS 251 Intermediate Programming Methods and Classes
CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationCS 251 Intermediate Programming Methods and More
CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationSpring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques
1 CPSC2620 Advanced Programming Spring 2003 Instructor: Dr. Shahadat Hossain 2 Today s Agenda Administrative Matters Course Information Introduction to Programming Techniques 3 Course Assessment Lectures:
More informationJAVA: A Primer. By: Amrita Rajagopal
JAVA: A Primer By: Amrita Rajagopal 1 Some facts about JAVA JAVA is an Object Oriented Programming language (OOP) Everything in Java is an object application-- a Java program that executes independently
More informationCOMP 202. More on OO. CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading
COMP 202 CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading More on OO COMP 202 Objects 3 1 Static member variables So far: Member variables
More information2 rd class Department of Programming. OOP with Java Programming
1. Structured Programming and Object-Oriented Programming During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach
More informationAnatomy of a Class Encapsulation Anatomy of a Method
Writing Classes Writing Classes We've been using predefined classes. Now we will learn to write our own classes to define objects Chapter 4 focuses on: class definitions instance data encapsulation and
More informationIntroduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University
Introduction to Computers and Programming Languages CS 180 Sunil Prabhakar Department of Computer Science Purdue University 1 Objectives This week we will study: The notion of hardware and software Programming
More informationCS111: PROGRAMMING LANGUAGE II
CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A
More informationScheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7
Scheme Textbook, Sections 13.1 13.3, 13.7 1 Functional Programming Based on mathematical functions Take argument, return value Only function call, no assignment Functions are first-class values E.g., functions
More informationVARIABLES AND TYPES CITS1001
VARIABLES AND TYPES CITS1001 Scope of this lecture Types in Java the eight primitive types the unlimited number of object types Values and References The Golden Rule Primitive types Every piece of data
More informationBoolean Arithmetic. From Nand to Tetris Building a Modern Computer from First Principles. Chapter 2
From Nand to Tetris Building a Modern Computer from First Principles Chapter 2 Boolean Arithmetic These slides support chapter 2 of the book The Elements of Computing Systems By Noam Nisan and Shimon Schocken
More informationEXAM Computer Science 1 Part 1
Maastricht University Faculty of Humanities and Science Department of Knowledge Engineering EXAM Computer Science 1 Part 1 Block 1.1: Computer Science 1 Code: KEN1120 Examiner: Kurt Driessens Date: Januari
More informationAnatomy of a Method. HW3 is due Today. September 15, Midterm 1. Quick review of last lecture. Encapsulation. Encapsulation
Anatomy of a Method September 15, 2006 HW3 is due Today ComS 207: Programming I (in Java) Iowa State University, FALL 2006 Instructor: Alexander Stoytchev Midterm 1 Next Tuesday Sep 19 @ 6:30 7:45pm. Location:
More informationAn introduction to Java II
An introduction to Java II Bruce Eckel, Thinking in Java, 4th edition, PrenticeHall, New Jersey, cf. http://mindview.net/books/tij4 jvo@ualg.pt José Valente de Oliveira 4-1 Java: Generalities A little
More informationMachine (Assembly) Language
Machine (Assembly) Language Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 4: Machine Language
More informationPackages & Random and Math Classes
Packages & Random and Math Classes Quick review of last lecture September 6, 2006 ComS 207: Programming I (in Java) Iowa State University, FALL 2006 Instructor: Alexander Stoytchev Objects Classes An object
More informationLecture 06: Classes and Objects
Accelerating Information Technology Innovation http://aiti.mit.edu Lecture 06: Classes and Objects AITI Nigeria Summer 2012 University of Lagos. What do we know so far? Primitives: int, float, double,
More informationImperative Languages!
Imperative Languages! Java is an imperative object-oriented language. What is the difference in the organisation of a program in a procedural and an objectoriented language? 30 class BankAccount { private
More information1007 Imperative Programming Part II
Agenda 1007 Imperative Programming Part II We ve seen the basic ideas of sequence, iteration and selection. Now let s look at what else we need to start writing useful programs. Details now start to be
More informationCS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class
CS112 Lecture: Defining Classes Last revised 2/3/06 Objectives: 1. To describe the process of defining an instantiable class Materials: 1. BlueJ SavingsAccount example project 2. Handout of code for SavingsAccount
More informationCSEN401 Computer Programming Lab. Topics: Introduction and Motivation Recap: Objects and Classes
CSEN401 Computer Programming Lab Topics: Introduction and Motivation Recap: Objects and Classes Prof. Dr. Slim Abdennadher 16.2.2014 c S. Abdennadher 1 Course Structure Lectures Presentation of topics
More informationVirtual Machine (Part II)
IDC Herzliya Shimon Schocken Virtual Machine (Part II) Shimon Schocken Spring 2005 Elements of Computing Systems 1 Virtual Machine II (Ch. 8) Lecture plan 2 x = ( b + b 4 a c) / 2a if if ~(a = 0) 0) x
More informationProgramming with Java
Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules
More informationAnnouncements. Last modified: Fri Sep 8 00:59: CS61B: Lecture #7 1
Announcements Sign-ups for weekly group tutoring offered by the course tutors have been released! Form will close on Saturday, 9/9, at 11:59PM. You will receive room and time assignments on Sunday via
More informationLecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8
Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How
More informationObject-oriented basics. Object Class vs object Inheritance Overloading Interface
Object-oriented basics Object Class vs object Inheritance Overloading Interface 1 The object concept Object Encapsulation abstraction Entity with state and behaviour state -> variables behaviour -> methods
More informationIWKS 3300: NAND to Tetris Spring John K. Bennett. Assembler
IWKS 3300: NAND to Tetris Spring 2018 John K. Bennett Assembler Foundations of Global Networked Computing: Building a Modern Computer From First Principles This course is based upon the work of Noam Nisan
More informationZhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson
Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program
More informationSequential Logic. Building a Modern Computer From First Principles.
Sequential Logic Buildg a Modern Computer From First Prciples www.nand2tetris.org Elements of Computg Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 3: Sequential Logic slide 1 Usage
More informationCHAPTER 7 OBJECTS AND CLASSES
CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and
More informationProgramming Language Concepts: Lecture 2
Programming Language Concepts: Lecture 2 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2011 PLC 2011, Lecture 2, 6 January 2011 Classes and
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationCS 170, Section /3/2009 CS170, Section 000, Fall
Lecture 18: Objects CS 170, Section 000 3 November 2009 11/3/2009 CS170, Section 000, Fall 2009 1 Lecture Plan Homework 5 : questions, comments? Managing g g Data: objects to make your life easier ArrayList:
More informationCSc 520 Principles of Programming Languages
CSc 520 Principles of Programming Languages 9: Scheme Metacircular Interpretation Christian Collberg collberg@cs.arizona.edu Department of Computer Science University of Arizona Copyright c 2005 Christian
More informationExam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming
Exam 1 Prep Dr. Demetrios Glinos University of Central Florida COP3330 Object Oriented Programming Progress Exam 1 is a Timed Webcourses Quiz You can find it from the "Assignments" link on Webcourses choose
More informationChapter 4 Defining Classes I
Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the
More informationBSc. (Hons.) Software Engineering. Examinations for / Semester 2
BSc. (Hons.) Software Engineering Cohort: BSE/04/PT Examinations for 2005-2006 / Semester 2 MODULE: OBJECT ORIENTED PROGRAMMING MODULE CODE: BISE050 Duration: 2 Hours Reading Time: 5 Minutes Instructions
More informationCS 415 Midterm Exam Fall 2003
CS 415 Midterm Exam Fall 2003 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Questions will be graded on quality of answer. Please supply the best answer you can to
More informationCS61B Lecture #5: Arrays and Objects
CS61B Lecture #5: Arrays and Objects For faster response, please send urgent problems (like the lab files don t compile ) as mail to cs61b, rather than using class messages. Homeworks are generally due
More informationCS 11 java track: lecture 1
CS 11 java track: lecture 1 Administrivia need a CS cluster account http://www.cs.caltech.edu/ cgi-bin/sysadmin/account_request.cgi need to know UNIX www.its.caltech.edu/its/facilities/labsclusters/ unix/unixtutorial.shtml
More informationNews and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.!
True object-oriented programming: Dynamic Objects Reference Variables D0010E Object-Oriented Programming and Design Lecture 3 Static Object-Oriented Programming UML" knows-about Eckel: 30-31, 41-46, 107-111,
More informationCOMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette
COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.
More informationCSE 413 Winter 2001 Midterm Exam
Name ID # Score 1 2 3 4 5 6 7 8 There are 8 questions worth a total of 75 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to
More informationMutating Object State and Implementing Equality
Mutating Object State and Implementing Equality 6.1 Mutating Object State Goals Today we touch the void... (sounds creepy right... see the movie, or read the book, to understand how scary the void can
More informationJava Basics. Object Orientated Programming in Java. Benjamin Kenwright
Java Basics Object Orientated Programming in Java Benjamin Kenwright Outline Essential Java Concepts Syntax, Grammar, Formatting, Introduce Object-Orientated Concepts Encapsulation, Abstract Data, OO Languages,
More informationBM214E Object Oriented Programming Lecture 4
BM214E Object Oriented Programming Lecture 4 Computer Numbers Integers (byte, short, int, long) whole numbers exact relatively limited in magnitude (~10 19 ) Floating Point (float, double) fractional often
More information11/19/2014. Objects. Chapter 4: Writing Classes. Classes. Writing Classes. Java Software Solutions for AP* Computer Science A 2nd Edition
Chapter 4: Writing Classes Objects An object has: Presentation slides for state - descriptive characteristics Java Software Solutions for AP* Computer Science A 2nd Edition by John Lewis, William Loftus,
More informationEMBEDDED SYSTEMS PROGRAMMING Language Basics
EMBEDDED SYSTEMS PROGRAMMING 2015-16 Language Basics "The tower of Babel" by Pieter Bruegel the Elder Kunsthistorisches Museum, Vienna (PROGRAMMING) LANGUAGES ABOUT THE LANGUAGES C (1972) Designed to replace
More informationCompiling and Running a C Program in Unix
CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 95 ] Compiling and Running a C Program in Unix Simple scenario in which your program is in a single file: Suppose you want to name
More informationMethods (Deitel chapter 6)
Methods (Deitel chapter 6) 1 Plan 2 Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods
More informationWeek 9 Implementation
Week 9 Implementation Dr. Eliane l. Bodanese What is more important From a software engineering perspective: Good Gui? does what customer wants maintainable, extensible, reusable Commented Code? how is
More informationMethods (Deitel chapter 6)
1 Plan 2 Methods (Deitel chapter ) Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods
More informationLecture 7 Objects and Classes
Lecture 7 Objects and Classes An Introduction to Data Abstraction MIT AITI June 13th, 2005 1 What do we know so far? Primitives: int, double, boolean, String* Variables: Stores values of one type. Arrays:
More informationDesign Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8
Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns
More informationCOP4020 Programming Assignment 1 - Spring 2011
COP4020 Programming Assignment 1 - Spring 2011 In this programming assignment we design and implement a small imperative programming language Micro-PL. To execute Mirco-PL code we translate the code to
More informationCOP4020 Programming Languages. Functional Programming Prof. Robert van Engelen
COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts
More informationSelected Questions from by Nageshwara Rao
Selected Questions from http://way2java.com by Nageshwara Rao Swaminathan J Amrita University swaminathanj@am.amrita.edu November 24, 2016 Swaminathan J (Amrita University) way2java.com (Nageshwara Rao)
More informationGrade Weights. Language Design and Overview of COOL. CS143 Lecture 2. Programming Language Economics 101. Lecture Outline
Grade Weights Language Design and Overview of COOL CS143 Lecture 2 Project 0% I, II 10% each III, IV 1% each Midterm 1% Final 2% Written Assignments 10% 2.% each Prof. Aiken CS 143 Lecture 2 1 Prof. Aiken
More informationTHE UNIVERSITY OF WESTERN AUSTRALIA. School of Computer Science & Software Engineering CITS1001 OBJECT-ORIENTED PROGRAMMING AND SOFTWARE ENGINEERING
THE UNIVERSITY OF WESTERN AUSTRALIA School of Computer Science & Software Engineering CITS1001 OBJECT-ORIENTED PROGRAMMING AND SOFTWARE ENGINEERING SAMPLE TEST APRIL 2012 This Paper Contains: 12 Pages
More informationLecture 5: Methods CS2301
Lecture 5: Methods NADA ALZAHRANI CS2301 1 Opening Problem Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively. 2 Solution public static int sum(int i1, int i2) { int
More informationclass declaration Designing Classes part 2 Getting to know classes so far Review Next: 3/18/13 Driver classes:
Designing Classes part 2 CSC 1051 Data Structures and Algorithms I Getting to know classes so far Predefined classes from the Java API. Defining classes of our own: Driver classes: Account Transactions
More informationAssertions, pre/postconditions
Programming as a contract Assertions, pre/postconditions Assertions: Section 4.2 in Savitch (p. 239) Specifying what each method does q Specify it in a comment before method's header Precondition q What
More informationChapter 6: User-Defined Functions. Objectives (cont d.) Objectives. Introduction. Predefined Functions 12/2/2016
Chapter 6: User-Defined Functions Objectives In this chapter, you will: Learn about standard (predefined) functions Learn about user-defined functions Examine value-returning functions Construct and use
More informationMachine (Assembly) Language Human Thought
Where we are at: Machine (Assembly) Language Human Thought Abstract design hapters 9, 12 abstract interface H.L. Language & Operating Sys. ompiler hapters 10-11 abstract interface Virtual Machine Software
More informationCS61B Lecture #7. Announcements:
Announcements: CS61B Lecture #7 New discussion section: Tuesday 2 3PM in 310 Soda. New lab section: Thursday 2 4PM in 273 Soda. Programming Contest coming up: 5 October (new date). Watch for details. Last
More informationIntroduction to Java
Introduction to Java Module 1: Getting started, Java Basics 22/01/2010 Prepared by Chris Panayiotou for EPL 233 1 Lab Objectives o Objective: Learn how to write, compile and execute HelloWorld.java Learn
More informationFull file at
Chapter 2 Introduction to Java Applications Section 2.1 Introduction ( none ) Section 2.2 First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler
More informationContainer Vs. Definition Classes. Container Class
Overview Abstraction Defining new classes Instance variables Constructors Defining methods and passing parameters Method/constructor overloading Encapsulation Visibility modifiers Static members 14 November
More information