Electronic Engineering - Computer Science Exam (Autumn 2006), Exams of Computer Science

The instructions and questions for a computer science exam for students in the bachelor of engineering (honours) in electronic engineering program at cork institute of technology. The exam covers topics such as operator overloading, copy constructors, exception handling, dynamic memory allocation, and windows operating systems. Students are required to answer questions related to these topics and complete the exam within 3 hours.

Typology: Exams

2012/2013

Uploaded on 03/30/2013

lallit
lallit 🇮🇳

4

(27)

150 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Page 1 of 4
Bachelor of Engineering (Honours) in Electronic Engineering -Stage 3
(NFQ – Level 8)
Autumn 2006
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
All questions carry equal marks
Examiners: Prof. G. Hurley
Dr. S. Foley
Mr. D. O’Donovan
Mr. F. O’Reilly
Section A
Q1. (a) Discuss the benefits of operator overloading. [3 %]
(b) Define a class capable of storing a 3-D vector i.e. point = [x,y,z]. The class should
consist of a constructor, destructor and appropriate member data. [3 %]
(c) For the class in (b), show how the binary operators
i) ‘+’: plus
ii) ‘<<’: inserter
may be overloaded to add two 3-D vectors and display the contents of a vector,
respectively. [10 %]
(d) Explain, using (ii) in (c) above, why the concept of a friend function is necessary.
[4 %]
(e) Overload the ‘+=’ binary operator [5 %]
Q2. (a) What is a copy constructor and how does it differ from the assignment operator?
During your discussion, describe the circumstances under which each is called and
illustrate their use using examples. [9 %]
(b) (i) Describe the exception mechanism used for error handling in C++. [3 %]
pf3
pf4

Partial preview of the text

Download Electronic Engineering - Computer Science Exam (Autumn 2006) 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)

Autumn 2006

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 All questions carry equal marks

Examiners: Prof. G. Hurley Dr. S. Foley Mr. D. O’Donovan Mr. F. O’Reilly

Section A

Q1. (a) Discuss the benefits of operator overloading. [3 %]

(b) Define a class capable of storing a 3-D vector i.e. point = [x,y,z]. The class should consist of a constructor, destructor and appropriate member data. [3 %] (c) For the class in (b), show how the binary operators i) ‘+’: plus ii) ‘<<’: inserter may be overloaded to add two 3-D vectors and display the contents of a vector, respectively. [10 %] (d) Explain, using (ii) in (c) above, why the concept of a friend function is necessary. [4 %] (e) Overload the ‘+=’ binary operator [5 %]

Q2. (a) What is a copy constructor and how does it differ from the assignment operator?

During your discussion, describe the circumstances under which each is called and illustrate their use using examples. [9 %] (b) (i) Describe the exception mechanism used for error handling in C++. [3 %]

(ii) Write code to illustrate how an int may be tested to see if it is within a valid range e.g. 10 – 100. Any value outside this range should be considered an error and an exception should be generated to highlight this condition. [5 %]

(c) How is memory dynamically in C++? During your discussion, mention:

  • why malloc and free still exist but are no longer in use.
  • the distinction made between the dynamic allocation of a single and an array of classes giving code examples of each to illustrate your point. [8 %]

Q3. Define a class, base, capable of storing the characteristics of a plane travelling through Irish airspace. The class should store the name (7 letters), grid position (x,y [0-30]), speed (in grid units), direction (N,S,E,W). The class should possess an appropriate: i) Parameterised constructor [4 %] ii) Extractor which allows a plane’s details to be added [5 %] iii) Inserter to display the current list of details [5 %] iv) Member function to calculate the updated position. (The update is calculated using the speed and direction). [7 %] v) The class definition including all the above member functions. [4 %]

Section B

Q4. (a) Briefly compare using diagrams how Windows NT/2000 and Unix each interface with the hardware of the computer. Identify two components which are common to both Windows and Unix and explain what function they perform. [7 %] (b) Detail how the stack is accessed and manipulated 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 %] (c) Given the following C/C++ fragment, write the full Add2 routine in x86 assembly which takes as parameters two integers and shifts the first integer left by the amount specified in the second integer. extern int Add2(int A, int B);

int nNum1, nNum2; cin >> nNum1 >> nNum2; cout << “The Added Result is “ << Add2(nNum1, nNum2); cout << endl; [10 %]

Q6. (a) Describe the steps needed to write the following GUI based program in Visual C++.

This checks if a string is a palindrome (same when read from both sides) by reversing the string, which was entered in the normal box and outputting the reversed string.

[9 %]

(b) Describe the Graphics Subsystem available in Windows Programming. In particular you answer should explain: Device Context, Device Drivers, Virtual Screen, Stock Objects, ViewPort. [8 %]

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