IMPORTANT INSTRUCTIONS FOR THE STUDENTS:
• Answer All Questions in the same Question Paper under each question/section subsequently.
• Upload the same at your SUIT PORTAL only and Answer Sheet sent through EMAIL will not be accepted.
• The total size of this file should not exceed 1MB at the time of uploading it at portal so don’t insert images.
• Just type the answers under each question, avoid inserting images and follow the instructions at SUIT Portal.
• Before uploading, save the file in this format FINAL EXAM_DEPARTMENT_COURSE_Student Name_Reg#.doc
• Copying, plagiarism, and sharing your answers with other students is strictly prohibited and disciplinary action will be initiated against such students
• The students must submit this answer sheet on SUIT Portal as an assignment till last step as mentioned in this video/tutorial before the deadline: https://youtu.be/Vnpz5nKkfgM
Attempt All Questions. Each Question Carries 10 marks. Mention the references (if any) as footnotes or at the end after completing the question.
Q#1: Answer the questions related to the following code:
Class B
{
Public:
Void b1();
Protected:
Void b2();
};
Class A : public B
{
Public:
Void a1();
Protected:
Void a2();
};
Class C: public A
{
Public:
Void c1();
};
Void main ()
{
B temp1; A temp2; C temp3;
}
a) Name all member functions of all classes visible through temp1 in the main function?
b) Name all member functions of all classes visible through temp2 in the main function?
c) Name all member functions of all classes visible through temp3 in the main function?
d) Which class is the parent of class A?
e) Which class is the child of class A?
Solution#1 (to be typed here by the student)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Q#2 : Answer the questions related to the following code:
a) What is the output after applying n -- (decrement operator) to the output produced by line 21?
b) What is the output after applying -- n (decrement operator) to the output produced by line 22?
Solution#2 (to be typed here by the student)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Q#3 : Write down an algorithm/steps for the following program:
Solution#3 (to be typed here by the student)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Q#4: When do early and late binding occur? Differentiate the two with examples?
Solution#4 (to be typed here by the student)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Q#5: What do you know about virtual function and pure virtual function? Differentiate the two with examples?
Solution#5 (to be typed here by the student)
• ANS
• A virtual which is a function that is defined in the base class .
It is preceded by the keyword “virtual” which tells the compiler to include dynamic binding in program.
• it must provide a definition in the class where it is declared.
• A pure virtual function is a function that is only declared in the base class.
• It dose not provide a definition. The class becomes an abstract class if it includes a pure virtual function.
Differentiate between virtual function and a pure virtual function
virtual function pure virtual function
• It contains a definition in the class which it is declared
• The function definition is overridden by the derived class.
• The class that contains a virtual function is not an abstract class.
• Object of the base class that contains a virtual function can be created as it is not an abstract class
• They do not help create interface classes.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GET ANSWERS / LIVE CHAT