0% found this document useful (0 votes)
22 views3 pages

Ics 2201 Object Oriented Programming II

This document is an examination paper for the Bachelor of Science in Information Technology at Mombasa Polytechnic University College, focusing on Object Oriented Programming II. It includes instructions for candidates, five questions covering Java programming concepts, and tasks such as writing code and analyzing provided code snippets. The exam is structured to assess knowledge of programming structures, data types, loops, and applet creation.

Uploaded by

okumufelix023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

Ics 2201 Object Oriented Programming II

This document is an examination paper for the Bachelor of Science in Information Technology at Mombasa Polytechnic University College, focusing on Object Oriented Programming II. It includes instructions for candidates, five questions covering Java programming concepts, and tasks such as writing code and analyzing provided code snippets. The exam is structured to assess knowledge of programming structures, data types, loops, and applet creation.

Uploaded by

okumufelix023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

THE MOMBASA POLYTECHNIC UNIVERSITY COLLEGE

(A Constituent College of JKUAT)


(A Centre of Excellence)

Faculty of Engineering &


Technology
DEPARTMENT OF COMPUTER SCIENCE & INFORMATION
TECHNOLOGY

UNIVERSITY EXAMINATION FOR:


BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY
(BSc. IT JAN 11/MAY11/12)

ICS 2201: OBJECT ORIENTED PROGRAMMING II

END OF SEMESTER EXAMINATION


SERIES: DECEMBER 2012
TIME: 2 HOURS

Instructions to Candidates:
You should have the following for this examination
- Answer Booklet
This paper consist of FIVE questions
Answer question ONE (COMPULSORY) and any other TWO questions
Maximum marks for each part of a question are as shown
This paper consists of THREE printed pages

Question One (Compulsory)


a) Write the following structures using the correct syntax:
(i) If else structure (3 marks)
(ii) Nested if structure (4 marks)
(iii) While structure (2 marks)
(iv) Do while structure (5 marks)

b) Write a Java code to enter two integers and test the two integers to see if the large value entered is
exactly divisible by the smaller value. You must ensure that both values entered by the user must
be greater than zero, and then check to see which of the value is larger. Assume that a and b are
the two values entered by the user, write a code to perform the above task. (9 marks)
© 2012 – The Mombasa Polytechnic University College Page 1
c) Give an appropriate example for each of the following data types char, int, float, string.
(4 marks)

d) Name the THREE types of comments used in a Java program. (3 marks)


Question Two
a) Use the following Java code below to answer following questions: (10 marks)

int a, b;
for (a = 1 ; a <3; ++ a)
{
For (b = 1; b < =3; ++b)
system.out.printin (a + b);
system.out.printin (“ ∖ n );
}

(i) What will be the final value stored in variable a?


(ii) What will be the final value stored in variable b?
(iii) Which should be the correct output?
(iv) How many times would the second output statement be repeated?
(v) How many times would the first output statement be repeated.

b) Write the output that was produced by the following Java code. (10 marks)
Int a, b;
for (a = 1; a<=a;a++)
{
For (b – 1; b< =a; b++)
system.out.print (“*”);
system.out.print (“ ∖ n );
}
Question Three
a) Write a program that iterates through the odd numbers less than 30 and outputs the square of each
number using for loop. (12 marks)

b) Give the syntax to compile a Java source code. (4 marks)

c) Name the FOUR methods that are included in every applet. (4 marks)
Question Four
a) Write a Java code that required the user to input an integer between 1 to 100. Using a nested if,
check that the integer is within this range. If so, determine whether the integer is greater than or
less than 50. (12 marks)

b) (i) State the requirements when creating a variable name. (3 marks)

(ii) State which of the following are valid or invalid variable names, members, switch, 1BEE, price
$, employee – name. (5 marks)

© 2012 – The Mombasa Polytechnic University College Page 2


Question Five
a) Write a program that loops 30 times, and output only the numbers that are not divisible by 3 or 5.
Use the for loop and the if statement to code this program. (10 marks)

b) Write an applet program, to display the message “student Enrolment system” in blue color using
the drawstring () method. (10 marks)

© 2012 – The Mombasa Polytechnic University College Page 3

You might also like