1. Homepage
  2. Exam
  3. CPT106 SEMESTER 2021/22 Resit Exam - Question 3

CPT106 SEMESTER 2021/22 Resit Exam - Question 3

This question has been solved
Engage in a Conversation

 
CourseNana.COM

2nd SEMESTER 2021/22 Resit Exam CourseNana.COM

Undergraduate – Year 2 CourseNana.COM

C++ Programming and Software Engineering II CourseNana.COM

Exam Duration:   2 Hours CourseNana.COM

  CourseNana.COM

  CourseNana.COM


CourseNana.COM

  CourseNana.COM

INSTRUCTIONS TO CANDIDATES CourseNana.COM

  CourseNana.COM

1、    This is an open book resit exam. Please complete the exam independently and honestly. CourseNana.COM

2、    The total marks available are 100. CourseNana.COM

3、    Answer all questions in the answer booklet and submit it to LMO. There is NO penalty for providing a wrong answer. CourseNana.COM

4、   The duration is 2 hours. CourseNana.COM


   CourseNana.COM

Q3 CourseNana.COM

a) CourseNana.COM

  CourseNana.COM

Read the following codes. Fill in the blanks based on the output of the code fragment. CourseNana.COM

Total 20 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

i) CourseNana.COM

for (int k = 0; k < 9;      ) cout << ++k << ‘\t’; CourseNana.COM

Output is:  1    5    9 CourseNana.COM

(5) CourseNana.COM

  CourseNana.COM

  CourseNana.COM

ii) CourseNana.COM

int k = 0; while (k < 10){ CourseNana.COM

cout << k++; if (k%4==0) CourseNana.COM

     ; cout<<’;’; CourseNana.COM

} CourseNana.COM

  CourseNana.COM

Output is: 0;1;2;3 CourseNana.COM

(5) CourseNana.COM

  CourseNana.COM

  CourseNana.COM

b) CourseNana.COM

Given the following class definitions and main function: CourseNana.COM

  CourseNana.COM

class clA CourseNana.COM

{ CourseNana.COM

private: CourseNana.COM

int a; public: CourseNana.COM

virtual void print(){ CourseNana.COM

cout << "base class\n"; CourseNana.COM

} CourseNana.COM

~clA(){ CourseNana.COM

cout << "base class destructor\n"; CourseNana.COM

} CourseNana.COM

}; CourseNana.COM

  CourseNana.COM

class clB CourseNana.COM

{ CourseNana.COM

public: CourseNana.COM

int b; CourseNana.COM

void print(){ CourseNana.COM

cout << "print derived class\n"; CourseNana.COM

} CourseNana.COM

~clB(){ CourseNana.COM

cout << "derived class destructor\n"; CourseNana.COM

} CourseNana.COM

}; CourseNana.COM

  CourseNana.COM

void main(){ clB obj; CourseNana.COM

clA* ptr3 = &obj; ptr3->print(); CourseNana.COM

} CourseNana.COM

  CourseNana.COM

(1)  Write down one line of correct code to fix the compiling error of the program by updating the definition of class clB. (3) CourseNana.COM

(2)  Write down what would the main function print out? (3) CourseNana.COM

(3)  Write down the explanation of the output result of the program by using OOP concept. (4) CourseNana.COM

(10) CourseNana.COM


CourseNana.COM

Get the Solution to This Question

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
CPT106代写,C++ Programming and Software Engineering II代写,C++代写,Software Engineering代写,Exam代写,XTJLU代写,CPT106代编,C++ Programming and Software Engineering II代编,C++代编,Software Engineering代编,Exam代编,XTJLU代编,CPT106代考,C++ Programming and Software Engineering II代考,C++代考,Software Engineering代考,Exam代考,XTJLU代考,CPT106help,C++ Programming and Software Engineering IIhelp,C++help,Software Engineeringhelp,Examhelp,XTJLUhelp,CPT106作业代写,C++ Programming and Software Engineering II作业代写,C++作业代写,Software Engineering作业代写,Exam作业代写,XTJLU作业代写,CPT106编程代写,C++ Programming and Software Engineering II编程代写,C++编程代写,Software Engineering编程代写,Exam编程代写,XTJLU编程代写,CPT106programming help,C++ Programming and Software Engineering IIprogramming help,C++programming help,Software Engineeringprogramming help,Examprogramming help,XTJLUprogramming help,CPT106assignment help,C++ Programming and Software Engineering IIassignment help,C++assignment help,Software Engineeringassignment help,Examassignment help,XTJLUassignment help,CPT106solution,C++ Programming and Software Engineering IIsolution,C++solution,Software Engineeringsolution,Examsolution,XTJLUsolution,