Skip to content
VUBuddy

CS304 Final Term Short Notes

Object Oriented Programming PDF 847 KBUpdated 23 Oct 2026
Final term past paper CS304 Final Term Short Notes PDF 847 KB
vubuddy.com
Type
Final term past paper
Course
CS304 Object Oriented Programming
Size
PDF 847 KB
Updated
23 Oct 2026
Free download 0 of 3 used today
Download free · 847 KB

You get 3 free files a day on the website. Add the Chrome extension for 30 a day.

Unlimited downloads in the Android app Get it free on Google Play

Preview text

Text from pages 1, 2, 3 of 52. Download the file for all 52 pages.

CS304 Object Oriented Programming Lecture Wise Questions and Answers For Final Term Exam Preparation By Virtualians Social Network

Lecture 22 Short notes :

There‟s 3 type of inheritance in C++

1 Public 2 Private 3 Protected

Public inheritance implements „is a kind of‟ relationship.

In public inheritance , public members of the base class become public members of the derived class whereas private parts of the base class can not be accessed by derived class.

So derived class‟s interface comprises of 2 parts :1st part is derived class‟s own public member functions and the 2nd and the public member functions of the base class.

Whenever a derived class‟s object is to be created, the constructor of the base class would be executed first. First, Base class constructor will initialize the base class object and then derived class constructor will initialize the derived class object. From derived class constructor, a base class constructor can also be called explicitly. Base class Constructor Is always called first in either case.

Lecture 23:

Protected access specifier:

If a member is given „protected access specification‟ , such member can not be accessed from outside the class. However, a publicly derived class can access such protected members of the base class.

Derived object is a kind of base object. The base class pointer can point towards an object of derived class and vice versa.

cout << pPtr-> GetRollNo(); //Error because pPtr is a pointer to the person class and not the student class. And in person class, we have just assigned a name and not the RollNo(), which belongs to the student class. So we can not assume that a person is also a student, doctor etc. In other words, pPtr‟s static type is Person, and in Person class, we have not declared RollNo(). So, Access is governed by static type of the object/identity through which a member is being tried to be accessed. Same rule applies in case of Reference (&) as well.

Static Type: The type that is used to declare a reference or pointer is called its static type.

Q. IS-A and HAS-A Relationship

Ans

IS-A means you can have a class that "is a" something. Like a student "IS-A" person. This is used to describe one object being a subclass of another.

Sometimes there isn't a IS-A relationship between two classes, but a "HAS-A" is more appropriate. Example, a chair "HAS-A" leg. Or several. This is called aggregation, as opposed to inheritance.

Is a = Special kind of e.g. Car is special kind of Vehicle.

Has a = It physically has something, e.g Car has an engine.

  1. A House is a Building (inheritance);
  2. A House has a Room (composition);
  3. A House has an occupant (aggregation).

Q. Default constructor

Ans

In Default constructor all the parameters have default values. If no constructors are available for a class, the compiler implicitly creates a default parameterless constructor without a constructor initializer and a null body.

Q. Static Type Ans

The type that is used to declare a reference or pointer is called its static type e.g.

  1. In Person * pPtr = 0;

The static type of pPtr is Person * (Person pointer).

  1. Student s;

The static type of s is Student.

Q.Use of Protected key word:

Ans

The protected keyword specifies access to class members in the member-list up to the next access specifier (public or private) or the end of the class definition. Class members declared as protected can be used only by the following:

Member functions of the class that originally declared these members. Friends of the class that originally declared these members. Classes derived with public or protected access from the class that originally declared these members. Direct privately derived classes that also have private access to protected members.

Lec 24:

Lec 24: If we have to initialize a publicly derived class object to some other object through calling copy constructor, if there‟s no copy constructor in derived and base class, the compiler will create them automatically. First base class‟s part is copied and later on the derived one‟s. If user has written the copy constructor then it is necessary to call the base class‟s copy constructor from derived class‟s copy constructor. Base class‟s copy constructor will called from the member initialize of the derived class’s copy constructor.

Q. What is the purpose of following keyword in C++? how it is employed, kindly explain with examples:-

All CS304 files →
CS304 Object Oriented Programming All CS304 handouts, past papers, quizzes and MCQs in one place. Open course page

Get more out of VUBuddy, for free

Android app Free on Google Play
  • Unlimited downloads
  • The explanation behind every MCQ answer
  • Study offline on slow data
Get the Android app
Chrome extension Free on the Chrome Web Store
  • 30 downloads a day instead of 3
  • Sign in and buy Pro Semester here
Add to Chrome

One Pro Semester membership works in both the extension and the app.