Cork Institute of Technology Examination: Object Programming for Engineers CA, Exams of Computer Science

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

2012/2013

Uploaded on 04/13/2013

somitra-dave
somitra-dave 🇮🇳

4.7

(3)

55 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CORK INSTITUTE OF TECHNOLOGY
INSTITIÚID TEICNEOLAÍOCHTA CHORCAÍ
Semester 1 Examinations 2010 / 11
Module Title: Object Programming for Engineers CA
Module Code: COMP 8023 L02
School: Electrical and Electronic Engineering
Programme Title: Master of Engineering in Embedded Systems
Programme Code: ELES_L8_Y4
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.
pf3
pf4
pf5

Partial preview of the text

Download Cork Institute of Technology Examination: Object Programming for Engineers CA and more Exams Computer Science in PDF only on Docsity!

CORK INSTITUTE OF TECHNOLOGY

INSTITIÚID TEICNEOLAÍOCHTA CHORCAÍ

Semester 1 Examinations 2010 / 11

Module Title: Object Programming for Engineers CA

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).

  1. (a) Define a class called BasePoint, which is capable of representing an xy coordinate as private member data. The class should contain the following member functions: i. A parameterised constructor (taking the x-y coordinate values as parameters) with default arguments, where x and y are stored as private member data. [4 %]

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

  1. [2 %]