CSC 203 Examination Tutorials
CSC 203 Examination Tutorials
Question 1:
i. Identify and correct any syntax and logical errors in the snippet.
ii. Explain what the snippet does in summary.
iii. Write out the output from the program if the semicolon in line 2 is not
removed.
QUESTION 2
1. a) Write a simple Java code to calculate the sum of even number between 1 and 1000.
Make sure you use if and for loop control. Please print out the even numbers and also
print out their sum.
b) Write the syntax for the following control statements
if-else
for loop
while loop
do while loop
c) Explain the following
class in java and also mention the types of access modifiers that can be applied
to a class.
constructors and the types
data types and the types
method
variable
QUESTION 3
Write a program that reads the user’s age and then prints “You are a child” if the age <
18, “You are an adult” if 18 ≤ age < 65, and “You are a senior citizen” if age ≥ 65. Use
java scanner utility to perform this operation.
QUESTION 4
In a class, write a simple java code to calculate the area of a rectangle then print the
result. Then in the same class calculate the area of a circle and print the result. Ensure
that you solve the problems using methods within the class and local variables. Then use
the instance of the class to call the methods. Do not use return statement.
QUESTION 5
An engineer in a construction company requests your expertise to create a simple
computer program that will help in his construction work. He presents the following
shapes to you:
30cm
60cm
50.30cm
20.60cm
Now you are required to write a simple java class, that has class a variable and uses
constructors to calculate the perimeter and area of the shapes as they apply and prints the
results. (Follow the instruction strictly)
QUESTION 6
QUESTION 7
Lead City University was designed to accommodate 15, 000 students. At present, there are 9000
students and the growth rate is 5% per year. If the present growth rate is maintained, write a
program to determine the population of the school per year and in how many years' time the
capacity will be exceeded.