# sample3 - 1 CSE 1030 Introduction to Computer Science II...

This preview shows pages 1–3. Sign up to view the full content.

1 CSE 1030 Introduction to Computer Science II Sample Test 3 1 The classes A , B and C are related as follows. A B C 1 How are these two relations reFected in the implementation of class A ? 2 Consider the classes Named and Contact , the code of which can be found at the end of the test. Consider the following snippet of client code. String name = "Franck"; String address = "[email protected]"; Contact contact = new Contact(name, address); Draw the memory diagram corresponding to the execution having reached the end of the third line of the above client code. 3 Implement the method sumOfSquares of the class MyMath . ±or a given integer n , with n 1, this method returns the integer n s i =1 i 2 = 1 + 4 + ··· + ( n - 1) 2 + n 2 . Only recursive solutions will receive marks.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 /** * Returns 1 + 4 + . .. + (n-1)*(n-1) + n*n * * @param n an integer. * @pre. n >= 1 * @return the corresponding sum of squares. */ public static int sumOfSquares(int n)
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/13/2011 for the course CSE/MATH 1030 taught by Professor Mixprofs during the Winter '09 term at York University.

### Page1 / 3

sample3 - 1 CSE 1030 Introduction to Computer Science II...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online