CS1020_Midterm_AY1213S2_qns - CS1020 Midterm AY2012\/13 Semester 2 NATIONAL UNIVERSITY OF SINGAPORE SCHOOL OF COMPUTING MIDTERM TEST FOR CS1020 AY2012\/13

CS1020_Midterm_AY1213S2_qns - CS1020 Midterm AY2012/13...

This preview shows page 1 - 4 out of 19 pages.

CS1020 Midterm AY2012/13 Semester 2 - 1 of 19 - NATIONAL UNIVERSITY OF SINGAPORE SCHOOL OF COMPUTING MIDTERM TEST FOR CS1020 AY2012/13 Semester 2 CS1020 – Data Structures and Algorithms I 6 March 2013 Time allowed: 1 hour 30 minutes INSTRUCTIONS TO CANDIDATES1. This test paper consists of FIFTEEN (15)questions and comprises NINETEEN (19) printed pages. 2. This is a CLOSE BOOK test. You are allowed to bring in ONE (1) piece of handwrittenA4 double-sided reference sheet (no photocopies). 3. Fill in your Matriculation Number above clearly with a pen. Note that your matriculation number contains a letter at the back, for example: U084321X or A0091234E. 4. Answer all questions. 5. For MCQs (Q1 to Q12), use the OCR form provided. Shade and write down your matriculation number on the OCR form. You must use 2B pencilto shade/write on the OCR form, or the grading machine might not be able to register your shading. 6. For questions Q13 to Q15, fill in your answers in the space provided. You may use pencil or pen to write your answers. 7. You must submit both the OCR form and this document. It is your responsibility to ensure that you have submitted both to the invigilator at the end of the test. EXAMINER’S USE ONLY Section / Question Possible Marks Check A. MCQs 1-12 48 B. Q 13 6 B. Q 14 16 B. Q 15 30 Total 100 Matriculation number: (Write using a pen)
Background image
CS1020 Midterm AY2012/13 Semester 2 - 2 of 19 - SECTION A (12 Multiple Choice Questions: 48 Marks)Each question has only one correct answer. Shade your answers on the OCR form. 4 marks are awarded for each correct answer; no penalty for wrong answer. 1.Which of the following are NOT valid Java identifiers? i.$$$ ii._500 iii.True iv.final v.a/b A.Only (i) and (v) B.Only (ii) and (iii) C.Only (ii) and (iv) D.Only (iv) and (v) E.None of options (A), (B), (C), (D) is correct. 2.What is the output of the following code?class TestMystery {public static int[] mystery(int[] arr) { for (int i=0; i<arr.length; i++) { arr[i] *= 2;} return arr; } public static void main(String[] args) { int[] arr = {1}; int[] arr2 = mystery(arr); System.out.println(arr[0] + " " + arr2[0] + " " + (arr == arr2)); } }
Background image
3.Given a Bookclass which contains the instance method getPages(), and a Book object called harryPotter1, which of the following is a valid call?
Background image
Image of page 4

You've reached the end of your free preview.

Want to read all 19 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture