Get premium membership and access revision papers, questions with answers as well as video lessons.

Comp 408: Object – Oriented Programming (Java)  Question Paper

Comp 408: Object – Oriented Programming (Java)  

Course:Bachelor Of Science In Computer Science

Institution: Chuka University question papers

Exam Year:2013





CHUKA

UNIVERSITY

UNIVERSITY EXAMINATIONS
FOURTH YEAR EXAMINATIONS FOR THE AWARD OF
DEGRE IN BACHELOR OF SCIENCE (COMPUTER SCIENCE)
COMP 408: OBJECT – ORIENTED PROGRAMMING (JAVA)
STREAMS: COMP (SCIE) TIME: 2 HOURS
DAY/DATE: TUESDAY 23/4/2013 2.30 PM – 4.30 PM
INSTRUCTIONS:

• Answer QUESTION I and any other TWO QUESTIONS from section B
• This is a CLOSED BOOK EXAM, no reference materials allowed
• No use of mobile phones, no electronic calculators
• Write your answers legibly and use your time wisely.

QUESTION ONE: 30 MARKS

(a) Explain the meaning and the use of the following object oriented programming concepts:

(i) Object [2 Marks]

(ii) Class [2 Marks]

(b) With use of sketches to illustrate your answer, explain the concept of inheritance as used in object oriented programming. [6 Marks]

(c) Make use of class examples to show the difference between local and global variables. [4 Marks]

(d) Explain the difference between a constructor and a method. [4 Marks]

(e) What is an infinite loop? [2 Marks]
(f) Write a complete program that calculates and prints the product of three integers, the program should accepts all inputs from the keyboard, once all inputs are keyed in, it should then alert the user that the product of the numbers he entered are shown below: [10 Marks]


SECTION B: CHOOSE ONLY TWO QUESTIONS

QUESTION TWO: (20 MARKS)

(a) Given the following piece of code:
Public class Test {
Public static void main(String args[]) {
Int i=0, j=5;
For (; (i<3) && (j ++ < 10); i ++){
System.Out.print(‘” “ + i+””+j);
}
System.out.print(“”+ i9 ”” j);
}
}
What will be the result? [10 Marks]

(b) Given the following classes:
Public class person{
Public void tak(){system.out.print(“i am a person “); }
}
Public class student extends person {
Public class student extends person {
Public void tak() { system.out.print(“I am a student”);}
}
Giving reasons, explain what would be the output of this piece of code below: [10 Marks]

Public class Test {
Public static void main(string args[]){
Person p = new student();
p.talk();
}

QUESTION THREE (20 MARKS)

Discuss what you understand by object oriented programming and the common characteristics found in object oriented programming. Use code samples to elaborate your answer. Your discussion should be based on the following:

(i) Inheritance [5 Marks]

(ii) Polymorphism [5 Marks]

(iii) Encapsulation [5 Marks]

(iv) Instances [5 Marks]

QUESTION FOUR (20 MARKS)

(a) Illustrate with use of a counter controlled loop, how you would display a multiplication
table of squares of numbers from 1 – 10.

(b) With the use of an appropriate example, explain the use of new operator as used in object oriented programming. [5 Marks]

(c) Write a recursive method that returns a cube of any integer passed to it. [5 Marks]

QUESTION 5 (20 MARKS)

(a) What is an access modifier? Discuss the various types of access modifiers. [8 Mark]

(b) An array is an example of data structures used with java programming. Write a sample
java program that demonstrate the use of array objects. [12 Marks]

---------------------------------------------------------------------------------------------------------------------







More Question Papers


Popular Exams



Return to Question Papers