



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The cork institute of technology's semester 1 examination for the module object programming for engineers ca (comp 8023 l02) for the academic year 2010/11. The examination is closed-book and has a duration of 2 hours. It includes questions related to c++ classes, inheritance, constructors, and exception handling.
Typology: Exams
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Semester 1 Examinations 2010 / 11
Module Code: COMP 8023 L
School: Electrical and Electronic Engineering
Programme Title: Master of Engineering in Embedded Systems
Programme Code: ELES_L8_Y
External Examiner(s): Internal Examiner(s): Donal O‟Donovan
Instructions: Answer ALL questions. Question 1 should be answered using a computer and a printout handed up with your answer booklet , clearly indicating your name. [Examination percentage 50 %]
Question 2 should be answered in a hand-written examination booklet. [Examination percentage 50 %]
This is a closed-book examination
Duration: 2 hours
Sitting: Autumn 2011
Requirements for this examination:
Note to Candidates: Please check the Programme Title and the Module Title to ensure that you have received the correct examination paper. If in doubt please contact an Invigilator.
Using the Visual Studio programming environment, define the C++ classes described in 1.(a) 1.(b) and 1.(c).
ii. A public, pure virtual function, called „type‟ with no parameters. [3 %]
iii. A public virtual function called „info‟ with no parameters. The function displays the type (a string with the type of shape) and x , y positions. [3 %]
iv. A public member function to return the values of x and y. [3 %]
(b) Define a new class called Figure1P, which publically inherits BasePoint from 1. (a). [2 %] The class includes the following functionality: i. A parameterised constructor that takes x , y and r (radius) as arguments. Note, r is a public member data in Figure1P, and x and y are private members of the BasePoint class. [6 %] ii. Info(), for Figure1P, should display the radius, x and y values on- screen. [5 %]
(c) Define a new class called Circle, which publically inherits Figure1P from 1. (b). [2 %] The class includes the following functionality: i. A parameterised constructor that takes x , y and r (radius) as arguments. Note, r is a public member data in Figure1P, and x and y are private members of the BasePoint class. [6 %] ii. The type()function, for Circle, should display the text “Circle” on- screen. [5 %] iv. A public member function to return the values of x and y. [3 %] iii. Write an inserter to display the x , y and type properties of the Circle object on-screen. [8 %]
(a) Referring to Figure 1, answer the following:
i. State the name and purpose of the routines labelled „Comment 1, 2 and 3‟. [15 %] ii. Demonstrate the use of each mechanism in (i). [6 %]
iii. Explain why the „[]‟ are necessary in the line labelled „Comment 4‟ are required. [3 %] iv. Explain the result of the line labelled „Comment 5‟ and why is it necessary? [6 %]
(b) Explain the consequences of the access specifiers private , public and protected in the following cases:
i. Within an Individual class. [4 %] ii. During Inheritance between classes. [6 %]
(c) Explain the difference between function overloading and function overriding. [5 %] (d) #include <iostream.h> void Xhandler() { try { throw "hello"; // throw a char } catch(char *) {// catch a char cout << "Caught char * inside Xhandler\n"; throw ; } } main() { cout << "start\n"; try { Xhandler(); }
catch(char *) { cout << "Caught char * inside main\n"; } cout << "end"; return 0; } Figure 2
(Continued over)
(d) i. State the outcome of the program in Figure 2. Explain the outcome in each case. [3 %]
ii. Illustrate how ‘catch all’ options may be added to the program in Figure