CMT 211 2
CMT 211 2
FACULTY OF SCIENCE
REGULAR PROGRAMME
c) Explain any four packages that are shipped with java ( 4marks)
d) Explain with an example program any four Scanner class methods ( 8 marks)
e) List any four exceptions that may be thrown in a java program. ( 4marks)
Q2. a) Write a java program that receives a line of alphanumeric characters from
the command-line as arguments and then determine : (10 marks)
i) Number of alphabets characters.
ii) Number of numerical characters.
iii) Number of white spaces.
iv) Number of words.
b) i) Draw the Flow chart that will will generate 88 random integer number
between 1 and 67 and print them only if they are odd in columns of 8 .
( 5marks)
ii) Write the corresponding program . ( 5marks)
Q3. a) Give five differences that exist between Java and C++ ( 5 marks)
c) Assume a class Employee . Explain any five setter and any five getter
methods that may apply for the class. ( 10 marks)
Q4. a) Discuss the role Java JVM ,JRE and JDK . ( 6marks)
b) Write a java program that would return the maximum of any set of integer
numbers. ( 8marks)
Q5. a) Discuss any four types of errors that might lead to an exception.
(8 marks)
b) Define the terms (2 marks)
i) regular expression:
ii) transient: (2 marks)
b) You are given the string line pattern below. Write down the patterns that can be used to trace
i. The names, (2marks)
ii. Cat1 marks ( 2marks)
iii. Cat2 Marks ( 1marks)
iv. Exam Marks ( 1marks)
String rec = "Joseph Owino: Cat1 06,Cat2 12 and Exam 41";
*END*
Cuea/ACD/EXM/JANUARY – APRIL 2018 / COMPUTER / LIBRARY SCIENCE Page 2