Get premium membership and access revision papers, questions with answers as well as video lessons.
Ics 2204 Question Paper
Ics 2204
Course:Bachelor Of Science In Computer Science
Institution: Dedan Kimathi University Of Technology question papers
Exam Year:2012
DEDAN KIMATHI UNIVERSITY OF TECHNOLOGY
University Examinations 2012/2013 Academic Year
SECOND YEAR SEMESTER ONE EXAMINATION FOR THE DEGREE OF
BACHELOR OF SCIENCE IN COMPUTER SCIENCE
ICS 2204 PROGRAMMING LANGUAGES
DATE: 14th August 2012
INSTRUCTIONS: Answer Question One and Any Other Two questions
Question One
a) Explain the meaning of the following terms/phrases as used in programming languages
i. Human readability ii. Lexical structure of a language iii. Language definition
iv. Aliasing [6 marks] b)
i. Explain how a function/procedure written in imperative style could be
transformed into functional form [2 marks] ii. The following C/C++ function computes the power ab, where a is a floating point number and b is a non-negative integer:
double power(double a, int b)
{
int i;
double result=1.0; for(i=1;i<=b;i++) result*=a; return result; }
Rewrite the procedure in functional form. [4 marks]
c) Distinguish between the terms as used in relation to programming language design
i) Optimizability and Implementability ii) Reliability and Maintainability
iii) Generality and Orthogonality [ 6 marks]
d) Some of the stages of a modern compiler are often taken to be lexing, parsing and semantic analysis. Explain the purpose of each stage [4 marks]
e) Write a C++ class called triangle that stores the length of the base and height of a right triangle in two private instance variables. Include a constructor that sets these values and
define two-member function hypo ( ), which returns the length of the hypotenuse and the
second function area( ), which returns the area of the triangle. [4 marks] f) Explain any four advantages of static type checking [4 marks]
Question Two
a) What is the difference between a static type and a dynamic type? [2 marks]
b) Giving examples, clearly explain two ways of achieving static typing in programming
languages [4 marks]
c) The diagram below represents a swimming pool surrounded by a concrete footpath. The radius of the inner circle differs with that of the outer circle with 4 units. The outer circle of the pool is also fenced all around. The cost of fence is $7.50 per unit length while that of the concrete area is $4.50 per unit area.
Given the following circle class information for the pool above:
Class name: circle
Private data: radius
Member functions:
Constructor function
Area( )
Cicumfrence( )
Write a program that allows the user to input the radius of the pool .The program should calculate cost of fencing the pool and that of the concrete footpath, which should be displayed
accordingly. [10 marks]
d) Using suitable illustration, explain the difference between variable scope and lifetime of a
variable [4 marks]
Question Three
a) Describe how multi-way selection statements like the switch statement in C, C++ and Java are implemented. Why are they often more efficient than an equivalent if-else if construct?
[3 marks]
b) Write a C program that simulates a simple calculator. It reads two integers and a character. If the character is + the sum is displayed; if it is –, the difference is displayed; if it is a *, the product is displayed; if it is /, the quotient is displayed. Use a switch statement [7 marks]
c) i) Clearly distinguish between data abstraction and control abstraction [4 marks]
ii) Giving examples for each, explain the various types data abstractions with regard to their
levels [6 marks]
Question Four
a) Define Static arrays, fixed stack-dynamic arrays, stack-dynamic arrays and heap-dynamic arrays in regard to allocation and range biding. What are the advantages of each?
[6 marks]
b) Account for the importance of runtime environment when the program is under execution.
[3 marks]
c) With suitable illustrations, clearly explain the difference between compilation and
interpretation process [4 marks]
d) Using suitable code fragments in C, explain the application of the goto statement as a control
structure [4 marks]
e) Discuss the weakness of the imperative languages as relates to a paradigms for describing a computation [3 marks]
Question Five
a) Object-Oriented Programming (OOP) is an approach to program organization and development that attempts to eliminate some of the pitfalls of conventional programming methods by incorporating the best of structured programming features with several powerful new concepts
i) With aid of examples show that object-oriented programming languages widely support structured approach to programming. [6 marks]
ii) Discuss the means through which OOP has eliminated the pitfalls of
conventional programming. [6 marks]
b) Distinguish between the following
i) Parameter profile and subprogram protocol
iii) Activation record and Activation record instance [4 marks]
c) Explain the term subprogram linkage [2 marks]
d) Explain the concepts of logic programming paradigm [2 marks]
More Question Papers