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

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

View Full Document Right Arrow Icon
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 = "franck@cse.yorku.ca"; 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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
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)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online