UMD CMSC 131 - Lecture 15: Review of Aliasing & Mutability, Floating Point Calculations (7 pages)

Previewing pages 1, 2 of 7 page document View the full content.
View Full Document

Lecture 15: Review of Aliasing & Mutability, Floating Point Calculations



Previewing pages 1, 2 of actual document.

View the full content.
View Full Document
View Full Document

Lecture 15: Review of Aliasing & Mutability, Floating Point Calculations

96 views

Lecture Notes


Pages:
7
School:
University of Maryland, College Park
Course:
Cmsc 131 - Object-oriented Programming I
Object-oriented Programming I Documents

Unformatted text preview:

Lecture 15 Review of Aliasing Mutability Floating Point Calculations Last time 1 Unit testing and JUnit 2 Constructors revisited 3 equals Today 1 Project 4 assigned 2 Aliasing and Mutability 3 Floating Point calculations 4 Example class development Rational Numbers CMSC 131 Fall 2007 Jan Plane adapted from Bonnie Dorr Project 4 Is Assigned It is due Wednesday 10 31 at 11 00PM The project is closed You must complete the project by yourself Assistance can only be provided by teaching assistants TAs and instructors You must not look at other students code Start now Read entire assignment from beginning to end before starting to code Check out assignment now from CVS Follow the instructions exactly CMSC 131 Fall 2007 Jan Plane adapted from Bonnie Dorr 1 Taking Care of Corner Cases FancyWord example from Friday String of was a corner case that we needed to test for Write new test cases or new asserts in the test cases that already exist to take care of this What about null references as corner cases public void testNullAndEmpty FancyWord a new FancyWord null assertEquals null a toString FancyWord b new FancyWord assertEquals b toString CMSC 131 Fall 2007 Jan Plane adapted from Bonnie Dorr 2 What about Strings and Aliasing String objects are immutable fields cannot be changed once created Mutable objects fields values of instance variables can be changed e g Cat Student etc Immutable objects fields values of instance variables cannot be changed See String API http java sun com j2se 1 3 docs api java lang package summary html In this example y is created as an alias for String x b is created as an alias for Cat a but the results are different x Jan Plane y Jan Fluffy has been created Fluffy has been eaten Fluffy has 8 more lives a Fluffy 8 lives b Fluffy 8 lives CMSC 131 Fall 2007 Jan Plane adapted from Bonnie Dorr 3 Which picture represents the current status of memory Stack Heap cat a b Stack Heap cat a b Fred Fred CMSC 131 Fall 2007 Jan Plane adapted from Bonnie Dorr 4



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Lecture 15: Review of Aliasing & Mutability, Floating Point Calculations 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 Lecture 15: Review of Aliasing & Mutability, Floating Point Calculations 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?