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

Ics2304:Programming Paradigms Question Paper

Ics2304:Programming Paradigms 

Course:Computer Science

Institution: Meru University Of Science And Technology question papers

Exam Year:2013



1
QUESTION ONE – 30 MARKS
a. Explain each of the following statements as used in imperative languages and write an example of each. (4 Marks) i. Declarative statements ii. Imperative statements
b. Translate each of the following decision making structures to explicit goto snippets or fragments: (6 Marks) i. switch(a) { case patter1: statement1; break; case patter2: statement 2; default:defStatement; }
ii. For (statement 1; condition; statement2){ loopBody }
c. i. Differentiate between call-by-value and call-by-reference as used in declarative languages. (2 Marks) ii. Explain the advantages and disadvantages of using call-by-reference over call-by-value.(4 Marks) iii. Write a function that implements call-by-reference to swap the contents of the variables numHot and numCold. (4 Marks) d. i. Distinguish between a class and an object as used in object orientation. (2 Marks) ii. Explain three characteristics of an object. (3 Marks) e. i. Write a class definition of an entity set student with a few member data and member methods. (4 Marks) ii. Write a single statement to instantiate the class in (i) above with a single object. (1 Mark)
2
QUESTION TWO – 20 MARKS
a. Explain each of the following characteristics of a programming language. (4 Marks) i. Syntax ii. Semantics
b. Compare and contrast how imperative, functional and logical programming languages manipulated data. (6 Marks) c. Illustrate with example program fragments how each of the languages in (b) your above manipulates data. (6 Marks) d. Explain whether functional programming languages typically used in artificial intelligence applications can also be used for other types of applications. (4 Marks)
QUESTION THREE – 20 MARKS
a. With the aid of diagrams differentiate between multilevel inheritance and multiple inheritances. (4 Marks) b. Write simple program to implement each of the types of inheritance in (i) above. (8 Marks) c. Describe four concepts of the object oriented paradigms sighting their important to software development. (8 Marks)
QUESTION FOUR – 20 MARKS
a. Define the term recursive function. (2 Marks) b. State two benefits of using recursive functions as opposed to use of ordinary run-time or in-line functions. (2 Marks) c. The following equation is used to evaluate the sum of fibonacci numbers:
fibn+2 = fibn+1 + fibn
Construct a recursive function to compute the n-th Fibonacci number based on the expression above. (6 Marks)
d. Support for exception handling is present in most modern imperative and functional programming languages. i. With the aid of examples, explain what exception handling is and why it is useful for error handling. (7 Marks) ii. List down three problems associated with exception handling in a language. (3 Marks) QUESTION FIVE – 20 MARKS
a. Define the following terms as used in logic programming. (4 Marks)
b. Justify the effect of the variable quantifier ‘?’by construction a truth table for each of the following expressions given that X ranges over {4, 15} and Y over {7, 14}. (6 Marks) i. Greater than (Y,X) & greater than (12, Y) ii. ?X(greaterThan(Y,X) & greaterThan(12, Y))
c. With the aid of a suitable example program, discuss how facts, rules and goals are used in a prolog program. (10 Marks)






More Question Papers


Popular Exams



Return to Question Papers