2000FCExamAnswers

2000FCExamAnswers - - 11 - 415.101FC Answer book SURNAME:...

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

View Full Document Right Arrow Icon
- 11 - 415.101FC Answer book SURNAME: FORENAMES: DEGREE (BSc, COP, Etc): STUDENT IDENTIFICATION NUMBER: SIGNATURE: Examiner to complete: Question Mark Question Mark 1 5 2 6 3 7 4 8 TOTAL
Background image of page 1

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

View Full DocumentRight Arrow Icon
ANSWER BOOK - 12 - 415.101FC Surname: ID no: Forenames: 1. Fixing logic errors in a program. (5 marks) public class Q1 { public static void main(String[] args) { System.out.print("The sum of the numbers from 1 to 5 is: "); System.out.println(sum(1, 5)); } public static int sum(int start, int end) { int result, i; i = start; result = start; result = 0; while (i < end) { while (i <= end) { result = result + i; i++; } return result; } }
Background image of page 2
ANSWER BOOK - 13 - 415.101FC Surname: ID no: Forenames: 2. Method call output. (10 marks) all i gat or 3. Nested loop output. (10 marks) a) 8 b) 3 c) 1 4 7 2 5 8 3 6 9
Background image of page 3

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

View Full DocumentRight Arrow Icon
ANSWER BOOK - 14 - 415.101FC Surname: ID no: Forenames: 4. Completing a class. (20 marks) import java.awt.*; public class Planet { private int distance; private int diameter; private Color color;
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

2000FCExamAnswers - - 11 - 415.101FC Answer book SURNAME:...

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

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