2002FCTestQuestions

2002FCTestQuestions - C OMPSCI 101FC Principles of P...

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

View Full Document Right Arrow Icon
Family name or surname Given names Lab Day and Time (e.g. Monday 9) Instructions This test constitutes 15% of your final grade for the course. No one is to leave in the last 10 minutes. The test is closed book. No calculators are allowed. There are 100 marks in this test. The marks for each question are shown. Answer all questions in this booklet. Write your UPI on every page. You do NOT have to include JavaDoc comments unless the question asks for them. Use good indenting and naming styles. See page 15 for a list of methods you may find useful in your answers. You may use pages 15 and 16 as extra space. COMPSCI 101FC Principles of Programming Test and Answer Book Test - Thursday 18th April 6:30pm-8:00pm
Background image of page 1

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

View Full DocumentRight Arrow Icon
COMPSCI 101FC 2002 TEST AND ANSWER BOOK PAGE 2 STUDENT UPI: Student ID number Student UPI (Login name) Signature Marks: (for markers use only) Question Mark Question Mark 1 9 2 10 3 11 4 12 5 13 6 14 7 8 Total
Background image of page 2
COMPSCI 101FC 2002 TEST AND ANSWER BOOK PAGE 3 STUDENT UPI: Question 1 (11 marks) a) What would be printed out by the following code segment? int i = 10; double d = i / 3; System.out.println(d); (1 mark) b) What is printed by the following? System.out.println(7 + 7 + 7 + "7" + (7 + 7) + 7); (1 mark) c) Write an expression to generate a random integer between 8 and 13 (including 8 and 13) and assign it to the variable i . int i = (1 mark) d) What is the output of the following code segment? System.out.println("a"); System.out.print("a"); System.out.println("a"); System.out.print("a"); System.out.println("a" + "b"); System.out.println("a"); (2 marks)
Background image of page 3

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

View Full DocumentRight Arrow Icon
COMPSCI 101FC 2002 TEST AND ANSWER BOOK PAGE 4 STUDENT UPI: e) What is the output of the following code segment? double d = (int)(5.3 + 2.8); System.out.println(d); (1 mark) f) What is the output of the following code segment? System.out.println("\\n\""); (1 mark) g) What is the output of the following code segment? int i1 = 2 + 2 - 2 * 2 / 2; int i2 = 2 * 2 / 2 - 2 + 2; System.out.println(i1 + "." + i2); (1 mark) h) What is the output of the following code segment: int i = 9 - 8 - (7 * 6) / 5 + 4 - (3 + 2) * 2; System.out.println(i); (1 mark) i) What is the output of the following code segment: String s = "computer science"; String t = s.substring(3, 6); System.out.println(s.length() - t.length() + t); (2 marks)
Background image of page 4
COMPSCI 101FC 2002 TEST AND ANSWER BOOK PAGE 5 STUDENT UPI: Question 2 (8 marks) Complete the following method which displays the question passed as a parameter and waits for the user to type a response. If the first character of the response is a “y” or a “Y” then the method should return
Background image of page 5

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

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

This note was uploaded on 03/01/2012 for the course COMPSCI 101 taught by Professor Adrianaferraro during the Summer '12 term at Auckland.

Page1 / 18

2002FCTestQuestions - C OMPSCI 101FC Principles of P...

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

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