DOC PREVIEW
UT Arlington CSE 3302 - CSE 3302 Assignment 3

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CSE 3302 Assignment 3Due: 30 Sep 2010, 9:30am1 Generics in Java[10 pts] Consider this Java class:class Cell<T> {private T t;public Cell(T t) { this.t = t; }public void set(T t) { this.t = t;}public T get() { return t; }public boolean equalTo(Cell<T> other) { return this.t.equals(other.t); }public Cell<T> copy() { return new Box<T>(t); }}Which statements in the following code produce a compile-time error? Briefly explain.Cell<?> cell = new Cell<String>("hello");cell.set("world");cell.set(null);String s = cell.get();Object o = cell.get();boolean equal = cell.equalTo(cell);equal = cell.equalTo(new Cell<String>("hello"));Cell<?> cell1 = cell.copy();Cell<String> cell2 = cell.copy();Cell<? extends Number> cell3 = new Cell<Integer>(new Integer(1));cell3.set(new Integer(2));Number n = cell3.get();Cell<? super Integer> cell4 = new Cell<Integer>(new Integer(1));cell4.set(new Integer(2));Integer i = cell4.get();Object p = cell4.get();12 PrototypesConsider the following JavaScript code:function Point(x, y) { this.x = x; this.y = y; }Point.prototype.add = function(p) { return new Point(x + p.x, y + p.y); }var z = new Point(0,0)(a) [5 pts] Draw a sketch of the layout in memory of the object stored in z. Include its fields and anyother objects z itself transitively has references to.(b) [5 pts] Write JavaScript code to create a single new object that behaves exactly like z but alsocontains a color field.(c) [5 pts] Create a constructor for ColorPoint that returns an object containing x, y, and colorfields. The expression new ColorPoint(0,1,"blue") should create a new object with the x, y,and color fields initialized to. 0, 1, and "blue", respectively.(d) [5 pts] Now, create a constructor for ColorPoint that returns an object containing a color field,but which delegates to a Point object for the x and y


View Full Document

UT Arlington CSE 3302 - CSE 3302 Assignment 3

Documents in this Course
Smalltalk

Smalltalk

11 pages

Syntax

Syntax

5 pages

Syntax

Syntax

5 pages

JAVA

JAVA

57 pages

Semantics

Semantics

41 pages

Control

Control

74 pages

Load more
Download CSE 3302 Assignment 3
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CSE 3302 Assignment 3 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CSE 3302 Assignment 3 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?