ITI 1121 Midterm: ITI 1121 University of Ottawa 2010 Midterm-en

53 views15 pages

Document Summary

On the next page, you will nd the declarations of the classes animal, cat and famouscat. Answer: famouscat sylvester = new famouscat( "that"s not all folks!" Answer: cat garfield = new famouscat( "it"s my birthday!" Famouscat sylvester = new famouscat( "that"s not all folks!" sylvester = garfield; Famouscat sylvester = new famouscat( "that"s not all folks!" if ( boo instanceof cat ) { garfield = (cat) boo; sylvester. swap( garfield ); = tmp; public void swap( cat other ) { swap( weight, other. weight ); Pair p1, p2; p1 = new pair(); p1. setfirst( new string( "alpha" ) ); p2 = new pair(); p2. setfirst( new string( "bravo" ) ); p1. setsecond( p2 ); p2. setsecond( null ); In mathematics, a series is an in nite sequence of terms added together. The partial sum of the series, sn, is the sum of the rst n terms.