SECTION A: TRUE OR FALSE
This section consist of 20 questions. Answer all the questions
Each correct answer is allocated 2 Marks
Write True or False for Questions 1 to 20.
1. All while loops repeat the associated body less than once.
[2 Marks]
2. Package statement is not allowed on VPL elearning platform
[2 Marks]
3. A sequence of statements to a problem when written in a language that can easily be
understood by people and not by computers is called a program
[2 Marks]
4. All computers only understand one language known as machine language
[2 Marks]
5. Line I:// This is a sample program
Line 2: /* This is a plagiarism comments that that requires you
to insert them on top of VPL */
Line 2 above is an inline comments and Line 1 above is a multiline comment. [2 Marks]
6. The following are all valid identifier names: First_name, mySchool, package
7. The Java statement: Cdev = NI + N2 IK is not the same as cdev = nl + n2/k
[2 Marks]
[2 Marks]
8. The output of running: int C=4, D=7; D--; System.out.println(C*D); is 24
[2 Marks]
9. The output of 5+7*8 using precedence operator rule is equal to: 96
[2 Marks]
10. The output of (8+3)-27/3 using precedence operator rule is equal to: 2
[2 Marks]
11. Injava the statement sum++ is the same as sum=sum-1
[2 Marks]
12. Exception is an indication ofreading and writing to a file
[2 Marks]
13. Division by Oor index out of array range throws an exception handling
[2 Marks]
14. Sorting is the process of arranging a group of items into a defined order based on a particular
criteria
[2 Marks]
15. int, char and double are all examples of primitive data types in Java
[2 Marks]
16. In Java, the identifiers student, Student and sTudent are all the same.
[2 Marks]
17. Every source file must be named the same as the class declared in the file
[2 Marks]
18. Once an array is declared, the size cannot be changed.
[2 Marks]
19. An Array in the Java programming language has the ability to store only the same types of
values
[2 Marks]
20. For the expression (y>=z && a=b) to be true, both of (y>=z) and (a==b) must be true
[2 Marks]
SECTION B: FILL THE GAP
Examine the following cases, then for each case decide the correct data type to be used
and create a valid declaration and assignment.
21. The number of pages in a book:
[2 Marks]
22. Your name:
[2 Marks]
23. Whether or not a car is moving:
[2 Marks]
24. The amount of money in your bank:
[2 Marks]
25. The symbol you obtained in a certain subject ie 'A', or 'B', etc: [2 Marks]
26. The day you were born:
[2 Marks]
2