Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Spring 2007 Electronic Engineering Bachelor Exam - Computer Science, Exams of Computer Science

Exam questions for a computer science course in the bachelor of engineering (honours) in electronic engineering program at cork institute of technology. The exam covers topics such as polymorphism, constructors and destructors, exception handling, memory allocation, and assembly programming. Students are required to answer questions related to these topics and demonstrate their understanding through examples.

Typology: Exams

2012/2013

Uploaded on 03/30/2013

lallit
lallit šŸ‡®šŸ‡³

4

(29)

134 documents

1 / 5

Toggle sidebar

Related documents


Partial preview of the text

Download Spring 2007 Electronic Engineering Bachelor Exam - Computer Science and more Exams Computer Science in PDF only on Docsity! Cork Institute of Technology Bachelor of Engineering (Honours) in Electronic Engineering- Stage 3 (NFQ Level 8) Spring 2007 Computer Science (Time: 3 Hours) Read instructions carefully Section A: Answer any TWO questions Section B: Answer any TWO questions Use separate answer books for Sections A and B Examiners: Prof. G. Hurley Dr. S. Foley Mr. D. Oā€™Donovan Mr. F. Oā€™Reilly Section A 1. (a) Describe, using a basic example, how the virtual function mechanism is used to implement polymorphism, i.e., the ā€œone interface ā€“ multiple methodsā€ philosophy. [4 %] (b) Define a base class called ā€˜componentā€™ consisting of i), ii) and ii) below: i) Member data: ā€¢ ā€˜Device Nameā€™ - string ā€¢ ā€˜Number of Legsā€™ - integer ā€¢ ā€˜Valueā€™ - float ā€¢ ā€˜Currentā€™ - float ā€¢ ā€˜Voltageā€™ - float A constructor that accepts the following parameters: ā€¢ ā€˜Number of Legsā€™ and ā€˜Valueā€™ ii) Private member functions: ā€¢ SetValue(float CompValue) - sets the value of the component ā€¢ SetsLegNumber(int legNo) - sets the number of legs iii) Public, pure virtual member functions: ā€¢ OutputVoltage(void); - returns the number of legs ā€¢ InputCurrent (float iValue); - sets the device current [10 %] 2 (c) Derive a class called ā€˜resistorā€™ using (c) as a virtual base class. The class should possess the following member functions: i. A constructor that sets the ā€˜Device Nameā€™ and passes the ā€˜Number of Legsā€™ and ā€˜Valueā€™ to the base class. ii. Override the OutputVoltage() function to return the result ā€œCurrent * Resistorā€. [6 %] (d) Overload the member function OutputVoltage(void) function to include a bias voltage as a function argument , i.e., double OutputVoltage(float biasVoltage) using the formula ā€œCurrent * Resistor + biasVoltageā€. [5 %] 2. (a) Discuss the purpose and use of constructors and destructors. Show the typical syntax in each case. [6 %] (b) In connection with classes and inheritance, describe the sequence in which constructors and destructors are invoked? [4 %] (c) Illustrate, using an example, how constructor parameters may be passed from a derived class to a base class. [6 %] (d) Explain why a copy constructor is necessary? [2 %] (e) State the output of the program in Figure 1. Indicate, for each output, whether the copy or normal constructor is called and, in each case, indicate why. #include <iostream> using namespace std; class myclass { public: myclass() { cout << "Normal operation.\n"; } myclass(const myclass &obj) { cout << "Copy operation.\n"; } }; myclass f() { myclass ob; return ob; } void main (void) { myclass a; a = f(); } Figure 1 [7 %]
Docsity logo



Copyright Ā© 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved