{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2010S2ExamQuestions

# 2010S2ExamQuestions - CompSci 101 CONTINUED THE UNIVERSITY...

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

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CompSci 101 CONTINUED 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 - 2 - CompSci 101 ID: ........................................................... CONTINUED 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 ________ methodA( ____________________ ) { 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 ________ methodB( ____________________ ) { 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”); Question/Answer Sheet - 2 - CompSci 101 ID: ........................................................... CONTINUED 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 ________ methodA( ____________________ ) { 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 ________ methodB( ____________________ ) { 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”); (2 marks) Question/Answer Sheet - 3 - CompSci 101 ID: ........................................................... CONTINUED 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); (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

{[ snackBarMessage ]}

### Page1 / 30

2010S2ExamQuestions - CompSci 101 CONTINUED THE UNIVERSITY...

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

View Full Document
Ask a homework question - tutors are online