Class Test 2 A MEMO
Class Test 2 A MEMO
Duration: 90 min
Total: 35 Moderator: KS Tshehla
Full Marks: 35
Number of Pages: 11
Test Instructions
1. Read the instructions at the start of each question carefully.
2. Answer all questions on the Electronic Campus (EC) platform.
3. Use Notepad++ and the console only — no IDEs (like Eclipse, IntelliJ,
etc).
4. Test (debug) your code before submitting your answers.
5. Copy and paste your final answers into EC (do not cut and paste).
6. Keep a backup of each program in Notepad++ until you’ve confirmed your
submission.
7. Only scientific, non-programmable calculators are allowed.
8. Cellphones are not allowed during the test.
9. No sharing of calculators or stationery.
1
PPAFO5D/TROF05D CLASS TEST 2 A - MEMO May 2025
2.2 What is the correct method to read a String from the user?
A. readLine() A
B. keyboard.nextLine() B
C. input.nextString() C
D. String(); D
2.4 What will be the result of this operation: 7 / 2 in Java using integers?
A. 3 A
B. 3.5 B
C. 4 C
D. 0 D
2
PPAFO5D/TROF05D CLASS TEST 2 A - MEMO May 2025
integer
3.3 What is the difference between print() and println()? (2)
Class
3
PPAFO5D/TROF05D CLASS TEST 2 A - MEMO May 2025
A
B
C
D
E
Solution:
x = 9 \ 4 mod 5 * 3 ^ 2
x = 9 \ 4 mod 5 * 9
x = 2 mod 5 * 9
x=2*9
x = 18
4
PPAFO5D/TROF05D CLASS TEST 2 A - MEMO May 2025
5
PPAFO5D/TROF05D CLASS TEST 2 A - MEMO May 2025
A
begin
B
begin
//Declare variables
String sName
int iHoursWorked
double rPayRate, rSalary
//Input
C
D
E
F
G
H
//Process
I
//Output
J
end
end
6
PPAFO5D/TROF05D CLASS TEST 2 A - MEMO May 2025
Possible answer:
7
PPAFO5D/TROF05D CLASS TEST 2 A - MEMO May 2025
import java.util.Scanner;
//Input
System.out.print("Enter your price: ");
userPrice = scan.nextdouble;
//Randomize price
compPrice = 1 + Math.random(5000);
Possible solution:
8
PPAFO5D/TROF05D CLASS TEST 2 A - MEMO May 2025
9
PPAFO5D/TROF05D CLASS TEST 2 A - MEMO May 2025
Possible solution:
Component Description Marks
1. Input Handling Accepts name and 3 test marks 1
2. Variable Declarations Declares all required variables 1
3. Type Casting Uses (double) to get accurate average 1
4. Rounding Method Uses either DecimalFormat or Math.round() correctly 1
5. Output Displays name and rounded average to two decimal 1
places
10
PPAFO5D/TROF05D CLASS TEST 2 A - MEMO May 2025
11