BIJPP224 · JAVA PROGRAMMING I
MID-TERM EXAMINATION
Faculty Information and Communications Technology
Date 03 April 2019
Duration 1 Hour 30 Minutes
INFORMATION FOR CANDIDATE
1. This examination is worth 20% of the overall semester
assessment.
2. The total number of marks available for this examination is (70).
3. This practical test paper contains Four (4) pages including the
cover page.
INSTRUCTIONS TO CANDIDATE
1. Answer ALL questions in Section A and B.
2. Answer Section C practically (Using the PC).
3. If you make a mistake please put a single diagonal line through
the section you wish to be ignored by the examiner.
4. Return all examination papers and scripts upon completion of
the examination including any workings.
Section A: Answer all question(s) [10 Marks]
Student name:
______________________________No.____________________________________
1. What is the difference between do-while loop and a while [2]
loop?
Answer:
_________________________________________________________________
______________
_________________________________________________________________
______________
_________________________________________________________________
______________
_________________________________________________________________
______________
2. What is the output of the following code? [2]
public class JavaApplication13 {
public static void main (String[] args) {
int i=1;
do{ System.out.print(“red”);
++i;
}
while(i<=2)
}}
Answer:
3. Mention 2 typical parts of a for-loop [2]
Answer:
4. What happens when a switch statement has no “break” [2]
keyword in between cases?
Answer:
5. What is meant by casting ? [2]
Answer:
Section B: Answer all question(s) [60 Marks]
Question 1 [30]
Limkokwing University of Creative Technology Page 2 of 4
Faculty of Information and Communication Technology
You have been contracted to create a Java application that prints out the
numbers between 0 and 9 as corresponding to key presses on the
keyboard. You have to make use of a switch statement that defaults to,
“no number detected “in the event the user prints a non-numeric key.
Thus, create:
Create a NumberPressed class [1]
Variable int for input [2]
Switch statement implementation [9]
Escape sequence keyword definitions [6]
Prompting user inputs [2]
Printing of resulting feedback [3]
Correct implementation of the default case [5]
Note: Please note that all data is hard coded i.e. do not use the Scanner
class to get input.
Area assessed Comment( Mark(
s) s)
a) Correct class creation /
1
b) Correct variables’ declaration /
2
c) Correct switch statement /
9
d) Correct of loop escape keywords /
6
e) Prompting user input /
2
f) Correct feedback provided to screen /
3
g) Correct Default case implementation /
3
h) Correct syntax, indentation and commenting of code /
2
i) Correct program logic /
2
Question 2 [30]
Limkokwing University of Creative Technology Page 3 of 4
Faculty of Information and Communication Technology
You have been contracted to create another Java application to prompt
the user to choose the correct answer from a list of answer choices of a
question.
The user can choose to continue answering the question or stop answering
it. See the example below:
What is the command keyword to exit a loop in Java?
a. int
b. continue
c. break
d. exit
Enter your choice: b
Incorrect!
Again? press y to continue or N to stop
Correct and clear user input prompts [2]
Question structure and answer list [3]
Correct Program control statements (conditional statements ) [6]
Correct comparison statements to check for correct choice from user [6]
[5]
Use of loop to prompt replay from user
Escape from loop sequence in the event the user wishes to stop [2]
Correct print out in the event the user achieves the correct choice [3]
Area assessed Comment(s Mark(s)
)
j) Correct and clear user input prompt /
2
k) Question structure and answer list /
3
l) Correct Program control statements /
6
m) Correct comparison statements to check for correct /
choice 6
n) Loop to prompt replay /
5
o) Escape from loop /
2
p) Output print out /
3
q) User of correct Syntax and Logic /
2
Limkokwing University of Creative Technology Page 4 of 4
Faculty of Information and Communication Technology
Question paper checked and verified by (PRL): _____________________________Date:
22/03/2019
Limkokwing University of Creative Technology Page 5 of 4
Faculty of Information and Communication Technology