UNIVERSITY EXAMINATIONS: 2020/2021
EXAMINATION FOR THE DEGREES OF BACHELOR OF SCIENCE IN
APPLIED COMPUTING/ SOFTWARE DEVELOPMENT
BAC 2308 /BSD 3202: ADVANCED APPLICATION PROGRAMMING
FULL TIME/ PART TIME
DATE: DECEMBER, 2021 TIME: 2 HOURS
INSTRUCTIONS: Answer Question ONE and any other TWO Questions
QUESTION ONE (20 MARKS) – Compulsory
a) Properties provide a simple mechanism of enforcing encapsulation to class fields.
i) Illustrate the general syntax of a property. [4 marks]
ii) Consider private field mark of type integer defined in class Student.
➢ Write code segment that makes the field mark read-only. [2 marks]
➢ Write code segment that ensures the value assigned to field mark is not less than 0 or
greater than 100, otherwise prints “invalid marl”. [3 marks]
b) Explain the importance of Base Class Library and Common Language Runtime layers of
.NET framework to a C# program. [2 marks]
c) Distinguish between the following pair of terms as applied in C#. [4 marks]
i) Static and instance variables
ii) Reference data types and value data types
d) Given the following class definition, define a parameterized constructor initiliazes length and
width and a default constructor that initializes both values to 1. [5 marks]
private int length, width;
QUESTION TWO ( 15 MARKS)
a) Write one line of code to declare PI as a constant. [1 mark]
b) Describe the role of the following components of the .NET Framework in C# code compilation.
i.) Common Language Runtime Just-In-Time Compiler
ii.) Intermediate Code (IL)
c) A program is required that accepts the basic salary, allowance and tax rate and computes the
tax amount and net salary of an employee. The computations are done as follows: –
tax amount = tax rate / 100 * (basic salary + allowance)
net salary = basic salary – tax amount
Write a complete program that uses a class called Salary (object orientation) to implement the
above requirements. The class should have the following specifications.
➢ input – for data input
➢ output – for data output
➢ compute – for computing the tax amount and the net salary.
In addition, the class should have a constructor that initializes basic salary, allowance and tax
amount to specified values or 0 if no value is provided. [12 marks]
QUESTION THREE ( 15 MARKS)
a) Distinguish between the following terms as used in C#. [6 marks]
i.) Encapsulation and Polymorphism
ii.) Overriding and Overloading
iii.)Fields and methods
b) Making use of nested loops, write a console program to produce the following output.
c) Write a program that accepts an integer and checks whether it is evenly divisible by 9.
QUESTION FOUR ( 15 MARKS)
a) Define the term constructor [2 marks]
b) List two characteristics of a constructor. [2 marks]
c) State the major difference between the following controls. [4 marks]
i.) List Box and Combo Box
ii.) Check Box and Radio Button
d) Explain the difference between passing parameters by value and by reference to a method.
e) Write a complete program illustrating how to pass values by reference to a method.
& * * * *
* & * * *
* * & * *
* * * & *
* * * * &