Programming Languages and Techniques (CIS120)

Size: px
Start display at page:

Download "Programming Languages and Techniques (CIS120)"

Transcription

1 Programming Languages and Techniques (CIS120) Lecture 26 November 3, 2017 The Java ASM, Java Generics Chapter 24

2 Announcements HW7: Chat Server Available on Codio / InstrucNons on the web site Due Tuesday, November 14 th at 11:59pm Midterm 2 is next Friday, in class Last names A M Leidy Labs 10 (here) Last names N Z Meyerson B1 Review Session: Wednesday November 8 th at 6:00pm Coverage: Mutable state (in OCaml and Java) Objects (in OCaml and Java) ASM (in OCaml and Java) ReacNve programming (in Ocaml) Arrays (in Java) Subtyping, Simple Extension, Dynamic Dispatch (in Java) Sample exams from recent years posted on course web page Makeup exam request form: on the course web pages

3 When do constructors execute? How are fields accessed? What code runs in a method call? What is 'this'?

4 ASM refinement: The Class Table Class Table class Counter { private int x; public Counter () { x = 0; } public void incby(int d) { x = x + d; } public int get() { return x; } } class extends Counter { private int y; public (int inity) { y = inity; } public void dec() { incby(-y); } } The class table contains: the code for each method, references to each class s parent, and the class s stanc members. Object String tostring(){ boolean equals Counter extends Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends (int inity) { } void dec(){incby(-y);}

5 this Inside a non-stanc method, the variable this refers to the object on which the method was invoked. References to fields and methods in the same class as the currently running method have an implicit this. in front of them. class C { private int f; } public void copyf(c other) { this.f = other.f; } this other Stack C Heap f 0 C f 2

6 Example class Counter { private int x; public Counter () { x = 0; } public void incby(int d) { x = x + d; } public int get() { return x; } } class extends Counter { private int y; public (int inity) { y = inity; } public void dec() { incby(-y); } } // somewhere in main: d = new (2); d.dec(); int x = d.get();

7 with Explicit this and super class Counter extends Object { private int x; public Counter () { super(); this.x = 0; } public void incby(int d) { this.x = this.x + d; } public int get() { return this.x; } } class extends Counter { private int y; public (int inity) { super(); this.y = inity; } public void dec() { this.incby(-this.y); } } // somewhere in main: d = new (2); d.dec(); int x = d.get();

8 ConstrucNng an Object Workspace Stack Heap d = new (2); d.dec(); int x = d.get(); Class Table Object String tostring(){ boolean equals Counter extends Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends (int inity) { } void dec(){incby(-y);}

9 AllocaNng Space on the Heap Workspace Stack Heap Class Table super(); this.y = inity; d = _; d.dec(); int x = d.get(); this x 0 y 0 Object String tostring(){ boolean equals inity 2 Invoking a constructor: allocates space for a new object in the heap includes slots for all fields of all ancestors in the class tree (here: x and y) creates a pointer to the class this is the object s dynamic type runs the constructor body ager pushing parameters and this onto the stack Note: fields start with a sensible default - 0 for numeric values - null for references Counter extends Object Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

10 Calling super Workspace Stack Heap Class Table super(); this.y = inity; d = _; d.dec(); int x = d.get(); this x 0 y 0 Object String tostring(){ boolean equals inity 2 Counter extends Object Call to super: The constructor (implicitly) calls the super constructor Invoking a method or constructor pushes the saved workspace, the method params (none here) and a new this pointer. Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

11 Abstract Stack Machine Workspace Stack Heap Class Table super(); this.x = 0; d = _; d.dec(); int x = d.get(); this x 0 y 0 Object String tostring(){ boolean equals inity 2 _; this.y = inity; this Counter extends Object (Running Object s default constructor omihed.) Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

12 Assigning to a Field Workspace Stack Heap Class Table this.x = 0; d = _; d.dec(); int x = d.get(); this x 0 y 0 Object String tostring(){ boolean equals inity 2 _; this.y = inity; this Counter extends Object Assignment into the this.x field goes in two steps: - look up the value of this in the stack - write to the x slot of that object. Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

13 Assigning to a Field Workspace Stack Heap Class Table.x = 0; d = _; d.dec(); int x = d.get(); this x 0 y 0 Object String tostring(){ boolean equals inity 2 _; this.y = inity; this Counter extends Object Assignment into the this.x field goes in two steps: - look up the value of this in the stack - write to the x slot of that object. Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

14 Done with the call Workspace Stack Heap Class Table ; d = _; d.dec(); int x = d.get(); this x 0 y 0 Object String tostring(){ boolean equals inity 2 _; this.y = inity; this Counter extends Object Done with the call to super, so pop the stack to the previous workspace. Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

15 ConNnuing Workspace Stack Heap Class Table this.y = inity; d = _; d.dec(); int x = d.get(); this x 0 y 0 Object String tostring(){ boolean equals inity 2 Counter extends Object ConNnue in the class s constructor. Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

16 Workspace Stack Heap Class Table this.y = 2; d = _; d.dec(); int x = d.get(); this x 0 y 0 Object String tostring(){ boolean equals inity 2 Counter extends Object Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

17 Assigning to a field Workspace Stack Heap Class Table this.y = 2; d = _; d.dec(); int x = d.get(); this x 0 y 2 Object String tostring(){ boolean equals inity 2 Counter extends Object Assignment into the this.y field. (This really takes two steps as we saw earlier, but we re skipping some for the sake of brevity ) Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

18 Done with the call Workspace Stack Heap Class Table ; d = _; d.dec(); int x = d.get(); this x 0 y 2 Object String tostring(){ boolean equals inity 2 Counter extends Object Done with the call to the constructor, so pop the stack and return to the saved workspace, returning the newly allocated object (now in the this pointer). Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

19 Returning the Newly Constructed Object Workspace Stack Heap Class Table d = ; d.dec(); int x = d.get(); x 0 y 2 Object String tostring(){ boolean equals ConNnue execunng the program. Counter extends Object Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

20 AllocaNng a local variable Workspace Stack Heap Class Table d.dec(); int x = d.get(); d x 0 Object String tostring(){ y 2 boolean equals Counter extends Object Allocate a stack slot for the local variable d. Note that it s mutable (bold box in the diagram). Aside: since, by default, fields and local variables are mutable, we ogen omit the bold boxes and just assume the contents can be modified. Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

21 Dynamic Dispatch: Finding the Code Workspace Stack Heap Class Table.dec(); int x = d.get(); d x 0 Object String tostring(){ y 2 boolean equals Counter extends Object Invoke the dec method on the object. The code is found by pointer chasing through the class hierarchy. This is an example of dynamic dispatch: Which code is run depends on the dynamic class of the object. (In this case,.) Search through the methods of the, class trying to find one called dec. Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

22 Dynamic Dispatch: Finding the Code Workspace Stack Heap Class Table this.incby(-this.y); d Object _; int x = d.get(); this x 0 y 2 String tostring(){ boolean equals Counter extends Object Call the method, remembering the current workspace and pushing the this pointer and any arguments (none in this case). Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

23 Reading a Field s Contents Workspace Stack Heap Class Table this.incby(-.y); d Object _; int x = d.get(); this x 0 y 2 String tostring(){ boolean equals Counter extends Object Read from the y slot of the object. Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

24 Dynamic Dispatch, Again Workspace Stack Heap Class Table.incBy(-2); d Object _; int x = d.get(); this x 0 y 2 String tostring(){ boolean equals Invoke the incby method on the object via dynamic dispatch. In this case, the incby method is inherited from the parent, so dynamic dispatch must search up the class tree, looking for the implementanon code. The search is guaranteed to succeed Java s stanc type system ensures this. Search through the methods of the class looking for one called incby. If the search fails, recursively search the parent classes. Counter extends Object Counter() { x = 0; } void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

25 Running the body of incby Workspace Stack Heap Class Table this.x = this.x + d; d Object this.x = -2; _; int x = d.get(); this _; x -20 y 2 String tostring(){ boolean equals d -2 Counter extends Object this Counter() { x = 0; } It takes a few steps Body of incby: - reads this.x - looks up d - computes result this.x + d - stores the answer (-2) in this.x void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

26 Ager a few more steps Workspace Stack Heap Class Table int x = d.get(); d Object x -2 String tostring(){ y 2 boolean equals Counter extends Object Counter() { x = 0; } Now use dynamic dispatch to invoke the get method for d. This involves searching up the class hierarchy again void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

27 Ager yet a few more steps Workspace Stack Heap Class Table d x -2 x -2 y 2 Object String tostring(){ boolean equals Counter extends Object Counter() { x = 0; } Done! (Phew!) void incby(int d){ } int get() {return x;} extends Counter (int inity) { } void dec(){incby(-y);}

28 Summary: this and dynamic dispatch When object s method is invoked, as in o.m(), the code that runs is determined by o s dynamic class. The dynamic class, represented as a pointer into the class table, is included in the object structure in the heap If the method is inherited from a superclass, determining the code for m might require searching up the class hierarchy via pointers in the class table This process of dynamic dispatch is the heart of OOP! Once the code for m has been determined, a binding for this is pushed onto the stack. The this pointer is used to resolve field accesses and method invocanons inside the code.

29 Inheritance Example public class Counter { private int x; public Counter () { x = 0; } public void incby(int d) { x = x + d; } public int get() { return x; } } class extends Counter { private int y; public (int inity) { y = inity; } public void dec() { incby(-y); } } // somewhere in main: d = new (2); d.dec(); int x = d.get(); Answer: -2 What is the value of x at the end of this computanon? NPE 7. Doesn't type check

30 StaNc members and the Java ASM

31 StaNc Members Classes in Java can also act as containers for code and data. The modifier static means that the field or method is associated with the class and not instances of the class. You can do a stanc assignment to ininalize a stanc field. class C { public static int x = 23; public static int somemethod(int y) { return C.x + y; } public static void main(string args[]) { } } // Elsewhere: C.x = C.x + 1; C.someMethod(17); Access to the stanc member uses the class name C.x or C.foo()

32 Based on your understanding of this, is it possible to refer to this in a stanc method? 1. No 2. Yes 3. I m not sure

33 Class Table Associated with C The class table entry for C has a field slot for x. Updates to C.x modify the contents of this slot: C.x = 17; C extends Object static x 23 static int somemethod(int y) { return x + y; } static void main(string args[]) { } A stanc field is a global variable There is only one heap locanon for it (in the class table) ModificaNons to such a field are visible everywhere the field is if the field is public, this means everywhere Use with care!

34 StaNc Methods (Details) StaNc methods do not have access to a this pointer Why? There isn t an instance to dispatch through! Therefore, stanc methods may only directly call other stanc methods. Similarly, stanc methods can only directly read/write stanc fields. Of course a stanc method can create instance of objects (via new) and then invoke methods on those objects. Gotcha: It is possible (but confusing) to invoke a stanc method as though it belongs to an object instance. e.g. o.somemethod(17) where somemethod is stanc Eclipse will issue a warning if you try to do this.

35 Java Generics Subtype Polymorphism vs. Parametric Polymorphism

36 Main idea: Subtype Polymorphism* Anywhere an object of type A is needed, an object that is a subtype of A can be provided. // in class C public static void times2(counter c) { c.incby(c.get()); } // somewhere else, extends Counter C.times2(new (3)); If B is a subtype of A, it provides all of A s (public) methods. *polymorphism = many shapes

37 Object Recap: Subtyping classes (form a tree) interfaces Displaceable Area DisplaceableImpl Shape Point Circle Rectangle Extends Implements Subtype by fiat - Interfaces extend (possibly many) interfaces - Classes implement (possibly many) interfaces - Classes (except Object) extend exactly one other class (Object by default) - Interface types (and arrays) are subtypes by fiat of Object

38 Is subtyping enough?

39 Mutable Queue ML Interface module type QUEUE = sig (* type of the data structure *) type 'a queue How can we translate this interface to Java? (* Make a new, empty queue *) val create : unit -> 'a queue (* Add a value to the end of the queue *) val enq : 'a -> 'a queue -> unit (* Remove the front value and return it (if any) *) val deq : 'a queue -> a end (* Determine if the queue is empty *) val is_empty : a queue -> bool

40 Java Interface module type QUEUE = sig interface ObjQueue { type 'a queue val create : unit -> 'a queue // no constructors // in an interface val enq : 'a -> 'a queue -> unit public void enq(object elt); val deq : 'a queue -> a public Object deq(); end val is_empty : a queue -> bool } public boolean isempty();

41 Subtype Polymorphism interface ObjQueue { public void enq(object elt); public Object deq(); public boolean isempty(); } ObjQueue q = ; q.enq(" CIS 120 "); A x = q.deq(); System.out.println(x.trim()); q.enq(new Point(0.0,0.0)); B y = q.deq(); What type for A? 1. String 2. Object 3. ObjQueue 4. None of the above

42 Subtype Polymorphism interface ObjQueue { public void enq(object elt); public Object deq(); public boolean isempty(); } ObjQueue q = ; q.enq(" CIS 120 "); Object x = q.deq(); System.out.println(x.trim()); q.enq(new Point(0.0,0.0)); B y = q.deq(); ß // Does Is this line valid? type check No! 1. // Yes What type for B? Object 2. No 3. It depends

43 Subtype Polymorphism interface ObjQueue { public void enq(object elt); public Object deq(); public boolean isempty(); } ObjQueue q = ; q.enq(" CIS 120 "); Object x = q.deq(); //System.out.println(x.trim()); q.enq(new Point(0.0,0.0)); B y = q.deq(); What type for B? 1. Point 2. Object // Is this valid? No! 3. ObjQueue // What type for B? Object 4. None of the above

44 Parametric Polymorphism (a.k.a. Generics) Big idea: Parameterize a type (i.e. interface or class) by another type. public interface Queue<E> { public void enq(e o); public E deq(); public boolean isempty(); } The implementanon of a parametric polymorphic interface cannot depend on the implementanon details of the parameter. e.g. the implementanon of enq cannot invoke any methods on o

45 Generics (Parametric Polymorphism) public interface Queue<E> { public void enq(e o); public E deq(); public boolean isempty(); } Queue<String> q = ; q.enq(" CIS 120 "); String x = q.deq(); System.out.println(x.trim()); q.enq(new Point(0.0,0.0)); // What type of x? String // Is this valid? Yes! // Is this valid? No!

46 Subtyping and Generics

47 Subtyping and Generics* Queue<String> qs = new QueueImpl<String>(); Queue<Object> qo = qs; qo.enq(new Object()); String s = qs.deq(); Ok? Ok? Ok? Ok? Sure! Let s see I guess Noooo! Java generics are invariant: Subtyping of arguments to generic types does not imply subtyping between the instannanons: Object String but Queue<Object> Queue<String> Hardest part to learn about generics and subtyping * Subtyping and generics interact in other ways too. Java supports bounded polymorphism and wildcard types, but those are beyond the scope of CIS 120.

48 Subtyping and Generics Which of these are true, assuming that class QueueImpl<E> implements interface Queue<E>? 1. QueueImpl<Queue<String>> is a subtype of Queue<Queue<String>> 2. Queue<QueueImpl<String>> is a subtype of Queue<Queue<String>> 3. Both 4. Neither

49 One Subtlety Unlike OCaml, Java classes and methods can be generic only with respect to reference types. Not possible to do: Queue<int> Must instead do: Queue<Integer> Java Arrays cannot be generic: Not possible to do: class C<E> { E[] genericarray; public C() { genericarray = new E[]; } }

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 26 March 23, 2016 Inheritance and Dynamic Dispatch Chapter 24 Inheritance Example public class { private int x; public () { x = 0; } public void incby(int

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 25 November 1, 2017 Inheritance and Dynamic Dispatch (Chapter 24) Announcements HW7: Chat Client Available Soon Due: Tuesday, November 14 th at 11:59pm

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 26 March 26, 2015 Inheritance and Dynamic Dispatch Chapter 24 public interface Displaceable { public int getx(); public int gety(); public void move

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 27 March 28, 2018 Java Generics Collections and Equality Chapters 25 & 26 Announcements HW7: Chat Server Available on Codio / Instructions on the web

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 25 March 18, 2013 Subtyping and Dynamic Dispatch Announcements HW07 due tonight at midnight Weirich OH cancelled today Help your TAs make the most

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 27 March 23 rd, 2016 Generics and Collections Chapter 25 HW #6 due Tuesday Announcements I will be away all next week (FP workshop in Germany) Monday's

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 24 October 29, 2018 Arrays, Java ASM Chapter 21 and 22 Announcements HW6: Java Programming (Pennstagram) Due TOMORROW at 11:59pm Reminder: please complete

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 27 Mar 23, 2012 Generics, CollecBons and IteraBon Announcements CIS Course Faire TODAY at 3PM, here HW08 is due on Monday, at 11:59:59pm Midterm 2

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 28 April 2, 2014 Generics and CollecCons Midterm 2 is Friday Announcements Towne 100 last names A - L DRLB A1 last names M - Z Review sessions: Tonight!

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 24 March 18, 2016 The Java ASM What is the value of ans at the end of this program? Counter[] a = { new Counter(), new Counter() ; Counter[] b = {

More information

CIS 120 Midterm II March 29, 2013 SOLUTIONS

CIS 120 Midterm II March 29, 2013 SOLUTIONS CIS 120 Midterm II March 29, 2013 SOLUTIONS 1 1. Java True/False (20 points) Circle T or F. a. T F In the Java ASM, object values are stored in the heap. b. T F In the Java ASM, method definitions are

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 26 Mar 21, 2012 EncapsulaBon & Queues CIS120 / Spring 2012 EncapsulaBon Object encapsulabon EncapsulaBon preserves invariants about the state of the

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 28 November 8, 2017 Overriding Methods, Equality, Enums Chapter 26 Announcements HW7: Chat Server Available on Codio / InstrucNons on the web site

More information

CIS 120 Midterm II March 31, 2017 SOLUTIONS

CIS 120 Midterm II March 31, 2017 SOLUTIONS CIS 120 Midterm II March 31, 2017 SOLUTIONS 1 1. OCaml and Java (14 points) Check one box for each part. a. The following OCaml function will terminate by exhausting stack space if called as loop 10: let

More information

CIS 120 Midterm II November 8, Name (printed): Pennkey (login id):

CIS 120 Midterm II November 8, Name (printed): Pennkey (login id): CIS 120 Midterm II November 8, 2013 Name (printed): Pennkey (login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 23 March 16, 2018 Arrays, Java ASM What is the value of ans at the end of this program? int[] a = {1, 2, 3, 4; int[] b = a; b[0] = 0; int ans = a[0];

More information

CIS 120 Midterm II November 8, 2013 SOLUTIONS

CIS 120 Midterm II November 8, 2013 SOLUTIONS CIS 120 Midterm II November 8, 2013 SOLUTIONS 1 1. Facts about OCaml and Java (15 points) For each part, circle true or false. a. T F The.equals method in Java is roughly similar to OCaml s = operator.

More information

CIS 120 Midterm II November 16, Name (printed): Pennkey (login id):

CIS 120 Midterm II November 16, Name (printed): Pennkey (login id): CIS 120 Midterm II November 16, 2012 Name (printed): Pennkey (login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing

More information

CIS 120 Midterm II November 7, Name (printed): Pennkey (login id):

CIS 120 Midterm II November 7, Name (printed): Pennkey (login id): CIS 120 Midterm II November 7, 2014 Name (printed): Pennkey (login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing

More information

CIS 120 Midterm II November 16, 2012 SOLUTIONS

CIS 120 Midterm II November 16, 2012 SOLUTIONS CIS 120 Midterm II November 16, 2012 SOLUTIONS 1 1. Java vs. OCaml (22 points) a. In OCaml, the proper way to check whether two string values s and t are structurally equal is: s == t s = t s.equals(t)

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 22 March 14 th, 2016 Object Oriented Programming in Java Java Bootcamp tonight Announcements Monday, March 14 from 6-8pm in Levine 101 (Wu & Chen)

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 22 March 14, 2018 Static Methods, Java Arrays Chapters 20 & 21 Announcements HW6: Java Programming (Pennstagram) Due: Tuesday the 20 th at 11:59pm

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 24 March 24, 2014 Java ASM Interfaces and Subtyping Announcements HW 07 due tomorrow at midnight Exam 2, in class, a week from Friday (April 4th) The

More information

CIS 120 Programming Languages and Techniques. Final Exam, May 3, 2011

CIS 120 Programming Languages and Techniques. Final Exam, May 3, 2011 CIS 120 Programming Languages and Techniques Final Exam, May 3, 2011 Name: Pennkey: My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 21 March 12, 2018 Java: Objects, Interfaces, Static Members Chapters 19 & 20 Announcements Java Bootcamp Tonight!! Towne 100, 6-8 pm HW06: Pennstagram

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 31 April 3, 2013 Overriding, Equality, and Casts Announcements HW 09 due Tuesday at midnight More informajon about exam 2 available on Friday Unfinished

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Name: Pennkey: CIS 120 Midterm II November 18, 2011

Name: Pennkey: CIS 120 Midterm II November 18, 2011 Name: Pennkey: CIS 120 Midterm II November 18, 2011 1 /20 2 /20 3 /20 4 /20 5 /20 Total /100 Do not begin the exam until you are told to do so. You have 50 minutes to complete the exam. There are 100 total

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 28 March 30, 2016 Collections and Equality Chapter 26 Announcements Dr. Steve Zdancewic is guest lecturing today He teaches CIS 120 in the Fall Midterm

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 36 April 23, 2014 Overriding and Equality HW 10 has a HARD deadline Announcements You must submit by midnight, April 30 th Demo your project to your

More information

CS-202 Introduction to Object Oriented Programming

CS-202 Introduction to Object Oriented Programming CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract

More information

Programming Languages and Techniques (CIS120e)

Programming Languages and Techniques (CIS120e) Programming Languages and Techniques (CIS120e) Lecture 25 Nov. 8, 2010 ExcepEons and the Java Abstract Stack Machine Announcements Homework 8 (SpellChecker) is due Nov 15th. Midterm 2 is this Friday, November

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 28 November 7, 2018 Overriding Methods, Equality, Enums, Iterators Chapters 25 and 26 Announcements HW7: Chat Server Available on Codio / Instructions

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 12 Thomas Wies New York University Review Last lecture Modules Outline Classes Encapsulation and Inheritance Initialization and Finalization Dynamic

More information

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 21 October 21 st, 2015 Transi@on to Java Announcements HW5: GUI & Paint Due Tomorrow, October 22 nd at 11:59pm HW6: Java Programming (Pennstagram)

More information

Data Abstraction. Hwansoo Han

Data Abstraction. Hwansoo Han Data Abstraction Hwansoo Han Data Abstraction Data abstraction s roots can be found in Simula67 An abstract data type (ADT) is defined In terms of the operations that it supports (i.e., that can be performed

More information

CS107 Handout 37 Spring 2007 May 25, 2007 Introduction to Inheritance

CS107 Handout 37 Spring 2007 May 25, 2007 Introduction to Inheritance CS107 Handout 37 Spring 2007 May 25, 2007 Introduction to Inheritance Handout written by Julie Zelenski, updated by Jerry. Inheritance is a language property most gracefully supported by the object-oriented

More information

Media Computation. Lecture 16.1, December 8, 2008 Steve Harrison

Media Computation. Lecture 16.1, December 8, 2008 Steve Harrison Media Computation Lecture 16.1, December 8, 2008 Steve Harrison Today -- Details of Creating Classes From requirements to classes Creating a class that will simulate a number game Practice going from requirements

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Inheritance and Polymorphism Recitation 10/(16,17)/2008 CS 180 Department of Computer Science, Purdue University Project 5 Due Wed, Oct. 22 at 10 pm. All questions on the class newsgroup. Make use of lab

More information

Name: Pennkey (eg, sweirich): CIS 120 Final Exam May 8, 2012

Name: Pennkey (eg, sweirich): CIS 120 Final Exam May 8, 2012 Name: Pennkey (eg, sweirich): CIS 120 Final Exam May 8, 2012 My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing this examination.

More information

Example: Count of Points

Example: Count of Points Example: Count of Points 1 class Point { 2... 3 private static int numofpoints = 0; 4 5 Point() { 6 numofpoints++; 7 } 8 9 Point(int x, int y) { 10 this(); // calling the constructor with no input argument;

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Inheritance and Polymorphism Dr. M. G. Abbas Malik Assistant Professor Faculty of Computing and IT (North Jeddah Branch) King Abdulaziz University, Jeddah, KSA mgmalik@kau.edu.sa www.sanlp.org/malik/cpit305/ap.html

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 11 February 5, 2018 Review: Abstract types Finite Maps Homework 3 due tomorrow at 11:59:59pm Announcements (Homework 4 is due Tuesday, 2/20, and won

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques () Lecture 20 February 28, 2018 Transition to Java Announcements HW05: GUI programming Due: THURSDAY!! at 11:59:59pm Lots of TA office hours today Thursday See Piazza

More information

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 28 March 25, 2013 ExcepDons Announcements HW 08 due tonight at midnight Weirich OH: 1:30 3PM today Midterm 2 is this Friday Towne 100 last names A

More information

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,

More information

Instance Members and Static Members

Instance Members and Static Members Instance Members and Static Members You may notice that all the members are declared w/o static. These members belong to some specific object. They are called instance members. This implies that these

More information

Binghamton University. CS-140 Fall Dynamic Types

Binghamton University. CS-140 Fall Dynamic Types Dynamic Types 1 Assignment to a subtype If public Duck extends Bird { Then, you may code:. } Bird bref; Duck quack = new Duck(); bref = quack; A subtype may be assigned where the supertype is expected

More information

Chapter 11 Inheritance and Polymorphism. Motivations. Suppose you will define classes to model circles,

Chapter 11 Inheritance and Polymorphism. Motivations. Suppose you will define classes to model circles, Chapter 11 Inheritance and Polymorphism 1 Motivations Suppose you will define classes to model circles, rectangles, and triangles. These classes have many common features. What is the best way to design

More information

OOP: Key Concepts 09/28/2001 1

OOP: Key Concepts 09/28/2001 1 OOP: Key Concepts Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring 09/28/2001 1 Overview of Part

More information

Administrivia. Java Review. Objects and Variables. Demo. Example. Example: Assignments

Administrivia. Java Review. Objects and Variables. Demo. Example. Example: Assignments CMSC433, Spring 2004 Programming Language Technology and Paradigms Java Review Jeff Foster Feburary 3, 2004 Administrivia Reading: Liskov, ch 4, optional Eckel, ch 8, 9 Project 1 posted Part 2 was revised

More information

Introduction to Software Testing Chapter 2.4 Graph Coverage for Design Elements Paul Ammann & Jeff Offutt

Introduction to Software Testing Chapter 2.4 Graph Coverage for Design Elements Paul Ammann & Jeff Offutt Introduction to Software Testing Chapter 2.4 Graph Coverage for Design Elements Paul Ammann & Jeff Offutt www.introsoftwaretesting.com OO Software and Designs Emphasis on modularity and reuse puts complexity

More information

Dialects of ML. CMSC 330: Organization of Programming Languages. Dialects of ML (cont.) Features of ML. Functional Languages. Features of ML (cont.

Dialects of ML. CMSC 330: Organization of Programming Languages. Dialects of ML (cont.) Features of ML. Functional Languages. Features of ML (cont. CMSC 330: Organization of Programming Languages OCaml 1 Functional Programming Dialects of ML ML (Meta Language) Univ. of Edinburgh,1973 Part of a theorem proving system LCF The Logic of Computable Functions

More information

Today s lecture. CS 314 fall 01 C++ 1, page 1

Today s lecture. CS 314 fall 01 C++ 1, page 1 Today s lecture Midterm Thursday, October 25, 6:10-7:30pm general information, conflicts Object oriented programming Abstract data types (ADT) Object oriented design C++ classes CS 314 fall 01 C++ 1, page

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 28 March 30, 2018 Overriding Methods, Equality, Enums, Iterators Chapters 25 and 26 Method Overriding When a subclass replaces an inherited method

More information

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction Lecture 13: Object orientation Object oriented programming Introduction, types of OO languages Key concepts: Encapsulation, Inheritance, Dynamic binding & polymorphism Other design issues Smalltalk OO

More information

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc. Chapter 13 Object Oriented Programming Contents 13.1 Prelude: Abstract Data Types 13.2 The Object Model 13.4 Java 13.1 Prelude: Abstract Data Types Imperative programming paradigm Algorithms + Data Structures

More information

Concepts of Programming Languages

Concepts of Programming Languages Concepts of Programming Languages Lecture 10 - Object-Oriented Programming Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages

More information

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. CMSC 131: Chapter 28 Final Review: What you learned this semester The Big Picture Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. Java

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques () Lecture 12 February 7, 2018 Partiality, Sequencing, Records Chapters 12, 13 Midterm 1 This Friday in class Review session Tonight, 6 7:30 PM DRLB A1 Announcements

More information

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University Day 3 COMP 1006/1406A Summer 2016 M. Jason Hinek Carleton University today s agenda assignments 1 was due before class 2 is posted (be sure to read early!) a quick look back testing test cases for arrays

More information

CSE 452: Programming Languages. Previous Lecture. From ADTs to OOP. Data Abstraction and Object-Orientation

CSE 452: Programming Languages. Previous Lecture. From ADTs to OOP. Data Abstraction and Object-Orientation CSE 452: Programming Languages Data Abstraction and Object-Orientation Previous Lecture Abstraction Abstraction is the elimination of the irrelevant and the amplification of the essential Robert C Martin

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 10 February 2, 2018 Abstract types: Sets Chapter 10 Announcements Homework 3 due Tuesday at 11:59:59pm Midterm 1 Friday, February 9, in class Covers

More information

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner. HAS-A Relationship Association is a relationship where all objects have their own lifecycle and there is no owner. For example, teacher student Aggregation is a specialized form of association where all

More information

Name: Pennkey: CIS 120 Final Exam December 21, Do not begin the exam until you are told to do so. You have 120 minutes to complete the exam.

Name: Pennkey: CIS 120 Final Exam December 21, Do not begin the exam until you are told to do so. You have 120 minutes to complete the exam. Name: Pennkey: CIS 120 Final Exam December 21, 2011 My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing this examination. Signature:

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 37 April 22, 2016 Encapsulation & Hashing How is the Game Project going so far? 1. not started 2. got an idea 3. submitted design proposal 4. started

More information

Lecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting

Lecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting Lecture 36: Cloning Last time: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting Today: 1. Project #7 assigned 2. equals reconsidered 3. Copying and cloning 4. Composition 11/27/2006

More information

Lecture 6. COMP1006/1406 (the OOP course) Summer M. Jason Hinek Carleton University

Lecture 6. COMP1006/1406 (the OOP course) Summer M. Jason Hinek Carleton University Lecture 6 COMP1006/1406 (the OOP course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments A1,A2,A3 are all marked A4 marking just started A5 is due Friday, A6 is due Monday a quick

More information

Lecture Notes on Programming Languages

Lecture Notes on Programming Languages Lecture Notes on Programming Languages 85 Lecture 09: Support for Object-Oriented Programming This lecture discusses how programming languages support object-oriented programming. Topics to be covered

More information

Polymorphism. CMSC 330: Organization of Programming Languages. Two Kinds of Polymorphism. Polymorphism Overview. Polymorphism

Polymorphism. CMSC 330: Organization of Programming Languages. Two Kinds of Polymorphism. Polymorphism Overview. Polymorphism CMSC 330: Organization of Programming Languages Polymorphism Polymorphism Definition Feature that allows values of different data types to be handled using a uniform interface Applicable to Functions Ø

More information

IST311. Advanced Issues in OOP: Inheritance and Polymorphism

IST311. Advanced Issues in OOP: Inheritance and Polymorphism IST311 Advanced Issues in OOP: Inheritance and Polymorphism IST311/602 Cleveland State University Prof. Victor Matos Adapted from: Introduction to Java Programming: Comprehensive Version, Eighth Edition

More information

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism Block 1: Introduction to Java Unit 4: Inheritance, Composition and Polymorphism Aims of the unit: Study and use the Java mechanisms that support reuse, in particular, inheritance and composition; Analyze

More information

Principles of Software Construction: Objects, Design, and Concurrency. Objects (continued) toad. Spring J Aldrich and W Scherlis

Principles of Software Construction: Objects, Design, and Concurrency. Objects (continued) toad. Spring J Aldrich and W Scherlis Principles of Software Construction: Objects, Design, and Concurrency Objects (continued) toad Spring 2012 Jonathan Aldrich Charlie Garrod School of Computer Science 2012 J Aldrich and W Scherlis Announcements

More information

Generic programming POLYMORPHISM 10/25/13

Generic programming POLYMORPHISM 10/25/13 POLYMORPHISM Generic programming! Code reuse: an algorithm can be applicable to many objects! Goal is to avoid rewri:ng as much as possible! Example: int sqr(int i, int j) { return i*j; double sqr(double

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

Lecture 5: Implementing Lists, Version 1

Lecture 5: Implementing Lists, Version 1 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 5: Implementing Lists, Version 1 Contents 1 Implementing Lists 1 2 Methods 2 2.1 isempty...........................................

More information

COMP 110/L Lecture 19. Kyle Dewey

COMP 110/L Lecture 19. Kyle Dewey COMP 110/L Lecture 19 Kyle Dewey Outline Inheritance extends super Method overriding Automatically-generated constructors Inheritance Recap -We talked about object-oriented programming being about objects

More information

Csci 102: Sample Exam

Csci 102: Sample Exam Csci 102: Sample Exam Duration: 65 minutes Name: NetID: Student to your left: Student to your right: DO NOT OPEN THIS EXAM UNTIL INSTRUCTED Instructions: Write your full name and your NetID on the front

More information

Computer Science II (20073) Week 1: Review and Inheritance

Computer Science II (20073) Week 1: Review and Inheritance Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system

More information

Inheritance (Part 5) Odds and ends

Inheritance (Part 5) Odds and ends Inheritance (Part 5) Odds and ends 1 Static Methods and Inheritance there is a significant difference between calling a static method and calling a non-static method when dealing with inheritance there

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 29 April 3, 2014 Overriding, Enums, Iterators public class Ref { private T contents; public void add(t e) { contents = e; Quiz (on paper) public

More information

CIS 110: Introduction to computer programming

CIS 110: Introduction to computer programming CIS 110: Introduction to computer programming Lecture 25 Inheritance and polymorphism ( 9) 12/3/2011 CIS 110 (11fa) - University of Pennsylvania 1 Outline Inheritance Polymorphism Interfaces 12/3/2011

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation

More information

C10: Garbage Collection and Constructors

C10: Garbage Collection and Constructors CISC 3120 C10: Garbage Collection and Constructors Hui Chen Department of Computer & Information Science CUNY Brooklyn College 3/5/2018 CUNY Brooklyn College 1 Outline Recap OOP in Java: composition &

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg

More information

Programming Languages 2nd edition Tucker and Noonan"

Programming Languages 2nd edition Tucker and Noonan Programming Languages 2nd edition Tucker and Noonan" Chapter 13 Object-Oriented Programming I am surprised that ancient and Modern writers have not attributed greater importance to the laws of inheritance..."

More information

Code Reuse: Inheritance

Code Reuse: Inheritance Object-Oriented Design Lecture 14 CSU 370 Fall 2008 (Pucella) Tuesday, Nov 4, 2008 Code Reuse: Inheritance Recall the Point ADT we talked about in Lecture 8: The Point ADT: public static Point make (int,

More information

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

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java

More information

CS 112 Programming 2. Lecture 06. Inheritance & Polymorphism (1) Chapter 11 Inheritance and Polymorphism

CS 112 Programming 2. Lecture 06. Inheritance & Polymorphism (1) Chapter 11 Inheritance and Polymorphism CS 112 Programming 2 Lecture 06 Inheritance & Polymorphism (1) Chapter 11 Inheritance and Polymorphism rights reserved. 2 Motivation Suppose you want to define classes to model circles, rectangles, and

More information

Object Oriented Programming. Java-Lecture 11 Polymorphism

Object Oriented Programming. Java-Lecture 11 Polymorphism Object Oriented Programming Java-Lecture 11 Polymorphism Abstract Classes and Methods There will be a situation where you want to develop a design of a class which is common to many classes. Abstract class

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Interface Abstract data types Version of January 26, 2013 Abstract These lecture notes are meant

More information

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1 Object-Oriented Languages and Object-Oriented Design Ghezzi&Jazayeri: OO Languages 1 What is an OO language? In Ada and Modula 2 one can define objects encapsulate a data structure and relevant operations

More information

G Programming Languages Spring 2010 Lecture 9. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 9. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 9 Robert Grimm, New York University 1 Review Last week Modules 2 Outline Classes Encapsulation and Inheritance Initialization and Finalization Dynamic

More information

CS 101 Spring 2006 Final Exam Name: ID:

CS 101 Spring 2006 Final Exam Name:  ID: This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Unlike the midterm exams, you have a full 3 hours to work on this exam. Please sign the honor pledge here: Page 1

More information

CIS 120 Final Exam May 7, Name (printed): Pennkey (login id):

CIS 120 Final Exam May 7, Name (printed): Pennkey (login id): CIS 120 Final Exam May 7, 2014 Name (printed): Pennkey (login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing this

More information