INFORMATICS 1A newPR
INFORMATICS 1A newPR
MODULE Informatics 1A
DURATION 3 hours
RJ
Answer ALL questions.
Multiple Choice
Write down the question number and the correct answer next to it, e.g. 1.21 B
1.2 When saving a Java file, the file name should always be the same as the:
A) Class name
B) Variable name
C) Object name
D) Method name
1.3 Consider the following code snippet and state the resulting value of num2:
int num1 = 30;
int num2 = 20;
num1 = num2 + 10;
A) 10
B) 50
C) Null
D) 20
1.4 An Integrated Development Environment (IDE) is a program that is designed to help programmers and
developers build:
A) Compilers
B) Software
C) Code
D) Instructions
A) Classes
B) Objects
C) Methods
D) Code blocks
1
RJ
1.6 Expression a = = b is called a:
A) Comparison statement
B) Assignment statement
C) Logical operator
D) Boolean expression
A) While structure
B) Do….while structure
C) For loop structure
D) If….else structure
if (x > y)
Max = x;
else
Max = y;
A) Adds x and y
B) Compares x and y
C) Divides x by y
D) Compares x to y and returns the maximum value
A) Repetition loops
B) Nested if….else
C) Sentinel loops
D) While loops
1.10 Consider the variables listed below. Which one of the following is an invalid variable name?
A) surname
B) _abc_
C) $total
D) 1surname
1.11 The double ampersand (&&) performs the AND function and is known as a:
A) Logical connective
B) Boolean connective
C) Decision connective
D) Variable connective
2
RJ
1.12 A loop designed to never end is called:
A) Sentinel loop
B) Counter-controlled loop
C) Infinite loop
D) Nested loop
A) 0
B) 2
C) 3
D) 1
1.14 Which one of the following expressions below is an example of a String data type?
A) “0”
B) ‘0’
C) [A] and [B]
D) None of the above
A) methods
B) operators
C) numbers
D) variables
A) String
B) Special character
C) Letter
D) Digit
3
RJ
1.19 What is the output type of relational operators?
A) Integer
B) Boolean
C) Characters
D) Double
A) Semicolon ;
B) Open brace {
C) Close brace }
D) None of the above
Write down the number and then the answer, e.g. 2.21 True
4
RJ
QUESTION 3 (20 Marks)
3.1 Java is a language which was developed in 1991 by a company called Sun Microsystems.
3.3 When you learn to program, mistakes will be made. Each time an error is made in a program; there is a
challenge of locating it.
4.1 Provide TWO (2) reasons for using comments in a program. (4 marks)
5.1 Methods have a unique name and follow the same naming rules as variables; explain the rules for
naming methods. (5 marks)
5.2 Using a for loop, write a method called lines() to output the following statement to the screen 100 times: ‘I must
practise my programming’. Call the method lines() in the main program. (15 marks)
END OF PAPER
5
RJ