2010S2ExamAnswers

2010S2ExamAnswers - THE UNIVERSITY OF AUCKLAND SECOND...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: THE UNIVERSITY OF AUCKLAND SECOND SEMESTER, 2010 Campus: City COMPUTER SCIENCE Principles of Programming (Time Allowed: TWO hours) NOTE: You must answer all questions in this exam. No calculators are permitted Answer in the space provided in this booklet. There is space at the back for answers that overflow the allotted space. Surname Forenames Student ID Login (UPI) Q1 (/6) Q4 (/33) Q7 (/6) Q10 (/10) Q2 (/10) Q5 (/6) Q8 (/6) Q3 (/10) Q6 (/6) Q9 (/7) Total /100 Question/Answer Sheet - - CompSci 101 ID: ........................................................... 2 Question 1 (6 marks) a) Complete the method header for the following method (i.e. complete the first line of the method definition). The method, methodA() , is called in the following way: boolean result = methodA(); private boolean methodA( String word ) { return word.length() == 0; } (2 marks) b) Complete the method header for the following method (i.e. complete the first line of the method definition). The method, methodB() , is called in the following way: methodB(123.45); private void methodB( double price ) { final double GST_RATE = 15.0; System.out.println (GST included: $ + price * GST_RATE); } (2 marks) c) What is the output when the following code is executed? String name1 = Java; String name2 = name1.toLowerCase(); System.out.println (name2 == java); false Question/Answer Sheet - - CompSci 101 ID: ........................................................... 2 Question 1 (6 marks) a) Complete the method header for the following method (i.e. complete the first line of the method definition). The method, methodA() , is called in the following way: boolean result = methodA(); private boolean methodA( String word ) { return word.length() == 0; } (2 marks) b) Complete the method header for the following method (i.e. complete the first line of the method definition). The method, methodB() , is called in the following way: methodB(123.45); private void methodB( double price ) { final double GST_RATE = 15.0; System.out.println (GST included: $ + price * GST_RATE); } (2 marks) c) What is the output when the following code is executed? String name1 = Java; String name2 = name1.toLowerCase(); System.out.println (name2 == java); false (2 marks) Question/Answer Sheet - - CompSci 101 ID: ........................................................... 3 Question 2 (10 marks) a) What output is produced by the following code? boolean a = false; boolean b = true; boolean c = true; System.out.println(a && b || c); true (2 marks) b) Write a Java boolean expression which tests whether the int variable, age , is between 18 and 65 (both inclusive)....
View Full Document

Page1 / 26

2010S2ExamAnswers - THE UNIVERSITY OF AUCKLAND SECOND...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online