CS304 Midterm Solved Subjective with References by Moaaz and Irfan
- Type
- Midterm past paper
- Course
- CS304 Object Oriented Programming
- Size
- PDF 297 KB
- Updated
- 23 Oct 2026
You get 3 free files a day on the website. Add the Chrome extensionSign in with the extension for 30 a day.
Preview text
Text from pages 2, 3, 4 of 14. Download the file for all 14 pages.
Q1. can constant object access the none constant member function of each class.
Answer: (Page 106) " Const objects can access only const member functions so chances of change of state of const objects once they are created are eliminated."
Q2. Give at least two problems that we should check when we overloading assignments operator ("=") in string class (unsolved)
Q3. Give c++ code to overloaded unary "--" oprators to comples member class.
Answer: (Page 165)
Q4. What is simple association? Explain it with the help of example.
Answer: (Page 49) The two interacting objects have no intrinsic relationship with other object. It is the weakest link between objects. It is a reference by which one object can interact with some other object.
- Customer gets cash from cashier
- Employee works for a company
Q5. explain the deference between the static variable of a class with none static variable with the help of example
The difference between static and non static members is only that a non static member is tied to an instance of a class although a static member is tied to the class, and not to a particular instance. That is, a static member is shared by all instances of a class although a non static member exists for each instance of class.
write c++ code for operator() ......5 marks
Answer: (Page 161)
Function Operator
public: char & operator()(int);
char & String::operator() (int pos){ assert(pos>0 && pos<=size); return bufferPtr[pos-1];
int main(){ String s1(“Ping”); char g = s1(2); // g = „i‟ s1(2) = „o‟; cout << g << “\n”; cout << str. GetString(); return 0;
Write c++ code for operator [] using string class.......5 marks.....
Answer: (Page 160) Subscript operator must be overloaded as member function of the class with one parameter of integer type,
public: char & operator[](int);
char & String::operator[]( int pos){ assert(pos>0 && pos<=size); return stringPtr[pos-1];
int main() { String s1(“Ping”); cout <<str. GetString()<< endl; s1[2] = „o‟; cout << str. GetString(); return 0;
static data members.......2.mark
Answer: (Page 108) “A variable that is part of a class, yet is not part of any object of that class, is called static data member”
What is interface give two real life examples?
Answer: (Page 18) Interface is a set of functions of an object that he wants to expose to other objects.
Interface of a Car is set of these functions
- Accelerate • Change Gear • Apply Brakes• Turn Lights On/Off
Interface of a Phone is set of these functions
- Input Number• Place Call • Disconnect Call • Add number to address book • Remove number • Update number
What is aggregation give example?
Answer: (Page 53) An object may contain a collection (aggregate) of other objects, the relationship between the container and the contained object is called aggregation, For Example: A room and its components like table, chair and bed etc are example of aggregation.
What is an abstract class?
Answer: (Page 21) Taking part of the objects and their functions that is related to the problem and ignore all other irrelative characteristic called abstraction
Q17. Can we create an array of objects for a class having user defined constructor? Justify your answer. (2 marks)
Answer: (Page 114) There must always be a default constructor if we want to create array of objects
Q18. Friend functions increase „Programming bugs‟. What is your opinion? (2 marks)
Answer: Yes friend functions can increase programming bugs some time.
Related CS304 files
All CS304 files →- CS304 Midterm Solved MCQs with References Set 2 by Moaaz Midterm PDF 308 KB
- CS304 Midterm Past Paper 6 Midterm PDF 69 KB
- CS304 Midterm MCQs with References by Moaaz Midterm PDF 326 KB
- CS304 Highlighted Handouts Set 5 Highlighted PDF 3.7 MB
- CS304 Quiz 1 Set 2 Quiz PDF 857 KB
- CS304 Final Term Solved Subjective with References by Moaaz Final term PDF 245 KB
Get more out of VUBuddy, for free
- Unlimited downloads
- The explanation behind every MCQ answer
- Study offline on slow data
- 30 downloads a day instead of 3
- Sign in and buy Pro Semester here
One Pro Semester membership works in both the extension and the app.