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

(27)

150 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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 %]
pf3
pf4
pf5

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 %]

(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 %]

  1. (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 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 %]

Section B

Q4 (a) Explain how the stack is accessed from an Assembly routine when receiving a function call from a C/C++ program. Examine parameter passing, local variables within the assembly routine and saving register values. [8 marks]

(b) Given the following C++ fragment, write a routine GeneralMaths in x86 assembly which takes as parameters three integers. If the first parameter is 1 , the next two parameters (two and three) are added together, else if the first parameters is 2, the next two parameters (two and three) are multiplied together.

extern GeneralMaths(int X, int Y, int Z); int nOperation, nX, nY; cout << “Which operation Enter 1 for Add, 2 for multiply.” << endl; cin >> nOperation; cout << “Enter the two values << endl; cin >> nX >> nY; cout << “The Result is “ << GeneralMaths(nOperation, nX, nY) << endl; [11 marks] (c) Describe from an architecture or software support basis, three similarities and three differences of the Unix and Windows 2000/XP operating Systems. [6 marks] Total: [25 marks]

Q5 (a) Explain how in an x86 Processor, Software Interrupts can be used to execute useful library functions. Your answer should describe the Vector Table, format of addresses and registers values read or changed. Name and describe one such Interrupt function. [9 marks]

(b) Explain the concept of Memory Segmentation as it applies to the Intel x86 family of micro- processors, including what segments there are, how physical addresses can be calculated and the different registers used to support segmentation. Give one way that segments can be specified/identified in x86 assembly programs. [8 marks]

(c) Describe using diagrams the process/sequence by which messages are passed from the Operating System to individual Windows C++ GUI applications. [8 marks] Total: [25 marks]

Q6 (a) The MFC Application Wizard and ClassWizard allow the acceleration of the writing of Visual C++ Applications. Describe 6 options and choices (6 in total) that they provide and the effects that these choices have, when configuring/designing your application. [8 marks]

(b) Design and provide the code for the program which will check two strings to see if they are the same, as shown below. Describe briefly how the GUI is designed saying what steps need to be done before writing any code. Provide the C++ code to read in the values from the GUI, perform the comparison and output the result. Hint: The CString class has an overloaded equality operator ‘==’ to allow two strings to be directly compared for equality. [9 marks]

(c) Describe the Graphics Subsystem available in Windows Programming. In particular your answer should explain Device Context, Device Drivers, Virtual Screen, Stock Objects, Viewport. [8 marks] Total: [25 marks]