GRETSA UNIVERSITY - THIKA
UNIVERSITY EXAMINATIONS
JANUARY - APRIL 2020 SEMESTER
DIPLOMA IN COMPUTER SCIENCE
COURSE CODE: DISD 043
COURSE TITLE: PROGRAMMING WITH JAVA
DATE: 23RD SEPT 2020 TIME: 8.00AM-11.00AM
INSTRUCTIONS TO CANDIDATES
a) SECTION A IS COMPULSORY.
b) SECTION B: ANSWER ANY OTHER THREE QUESTIONS.
NOTE: QUESTION ONE -40MARKS
: SECTION B-Each question should be out of 20marks
SECTION A: COMPULSORY (40 Marks)
Question One
a. With an example explain how a java programmer can implement the following concepts:
i. Variable; (2 Marks)
ii. Polymorphisim: (2 Marks)
iii. Inheritance; (2 Marks)
iv. Abstraction; (2 Marks)
v. Class and Object; (4 Marks)
b. State FIVE features of Java as a programming language that makes it one of the popular
programming language. (5 Marks)
c. State and Explain THREE types of access modifiers used in Java programming
language. (6 Marks)
d. Define the term comments as used in Java programming. (2 Marks)
e. Comments are important when used in programming. Support this statement.
(6 Marks)
f. The following Java program has been written using switch statement, rerwrite the
programm using Java if...else...elseif Statements. (6 Marks)
g. Most Java students confuse while loop with do...while loop, but are not the same. As a
Java programming student differentiate the TWO loops. (5 Marks)
SECTION B: ANSWER ANY THREE QUESTIONS
Question Two (20 Marks)
a. There are TWO main control structures in Java. State and explain. (4 Marks)
b. Write a Java code to output all odd numbers between 0 to 100. (6 Marks)
c. Explain the following terms with examples as used in Java programming language:
i. Break; (3 Marks)
ii. Continue. (2 Marks)
d. PARAMETERS and ARGUMENT are Java keywords used by methods. State their
differences with an example in each. (5 Marks)
Question three (20 Marks)
a. Define the term method overloading as used in java programming. (2 Marks)
b. Define the following terms with examples as used in Java programming:
i. Constructors; (2 Marks)
ii. Destructors. (2 Marks)
c. State the five rules that are used to define variable names in Java programming.
(5 Marks)
d. State FIVE types operators that are used in Java in programming. (5 Marks)
e. Java programming language is considered to be Object Oriented Programming(OOP).
Explain this feature. (2 Marks)
f. State TWO advantages of Java been Object Oriented Programming. (2 Marks)
Question Four
a. FOR is a loop that is used in Java. Explain its use with an example. (5 Marks)
b. Define the term function as used in Java. (2 Marks)
c. State and explain TWO types of functions used in Java programming, with examples.
(6 Marks)
d. Explain with examples of how the following string manipulation methods are used:
i. length( ); (2 Marks)
ii. indexOf(); (3 Marks)
iii. + operator; (2 Marks)
Question five
a. Define what is an infinite loop in Java and illustrate with an example. (4 Marks)
b. Define the term typecasting as used in Java programming, with examples in each.
(6 Marks)
c. State and explain FOUR data types that are found in Java. (4 Marks)
d. Define the term array as used in Java. (2 Marks)
e. State and explain TWO types of array available in the Java programming language.
(4 Marks)
f. Differentiate the following terms as used in java programming inheritance. (2 Marks)
i. Subclass;
ii. Superclass.
g. State FOUR applications of Java language. (4 Marks)