THEORY EXAMINATION (SEM–IV) 2016-17 OBJECT ORIENTED PROGRAMMING WITH C++

B.Tech Computer Science 0 downloads
₹29.00

Course: B.Tech (Computer Science / IT)
Subject Code: CS403
Subject Title: Object-Oriented Programming with C++
Exam Type: Theory
Duration: 3 Hours
Maximum Marks: 100

SECTION – A (10 × 2 = 20 Marks)

Short conceptual questions testing understanding of OOP fundamentals

No.ConceptExplanation
(a)GeneralizationProcess of extracting common properties and behaviors from multiple classes to create a base class.
(b)Abstract ClassA class with at least one pure virtual function; cannot be instantiated directly.
(c)this PointerImplicit pointer used to refer to the invoking object inside a member function.
(d)DestructorSpecial member function with ~ClassName() used to free resources when an object goes out of scope.
(e)PolymorphismAbility of a function or operator to behave differently based on input or object type — achieved via overloading or virtual functions.
(f)Derived AttributeAttribute computed from other attributes, not stored directly (e.g., total = price × quantity).
(g)InheritanceMechanism of deriving a new class from an existing one to reuse and extend its functionality.
(h)Characteristics of OOPsEncapsulation, inheritance, polymorphism, abstraction, reusability.
(i)Pure Virtual FunctionA virtual function declared as =0; defines an interface for derived classes.
(j)Inline FunctionFunction expanded inline to reduce function call overhead; declared with keyword inline.

SECTION – B (5 × 10 = 50 Marks)

Analytical and programming-based questions

(a) Copy Constructor

Used to initialize an object from another of the same class.

(b) Constructor Example – Area of Circle

 

#include <iostream> using namespace std; class Circle {  float r; public:  Circle(float radius) { r = radius; }  float area() { return 3.14 * r * r; } }; int main() {  Circle c1(5);  cout << "Area = " << c1.area(); }

(c) Function Overloading

Functions with the same name but different parameter lists.

(d) Operator Overloading

Overloading operators for user-defined types.
Example: Binary + operator

(e) OOP vs Procedural Programming

FeatureOOPProcedural
StructureClass-basedFunction-based
DataEncapsulatedGlobal
ReusabilityHighLimited
ExamplesC++, JavaC, Pascal

(f) Sorting Ten Integers (C++)

 

#include <iostream> using namespace std; int main() {  int a[10];  for(int i=0;i<10;i++) cin >> a[i];  sort(a, a+10);  for(int i=0;i<10;i++) cout << a[i] << " "; }

(g) Command Line Arguments – Factorial

 

#include <iostream> #include <cstdlib> using namespace std; int main(int argc, char* argv[]) {  int n = atoi(argv[1]);  int f=1; for(int i=1;i<=n;i++) f*=i;  cout << "Factorial = " << f; }

(h) Exception Handling

Handles runtime errors gracefully using try, catch, and throw.

SECTION – C (2 × 15 = 30 Marks)

Advanced C++ programming and conceptual application

Q3. (i) File Operations

File Handling in C++:

(ii) Class Template

 

template <class T> class Calculator { public:  T add(T a, T b) { return a + b; } }; int main() {  Calculator<int> c;  cout << c.add(4, 5); }

Q4. Inheritance (All Types with Example)

TypeExampleDescription
SingleA → BOne base, one derived class.
MultipleA,B → CDerived from multiple base classes.
MultilevelA → B → CDerived in successive levels.
HierarchicalA → B, COne base → many derived.
HybridCombinationMix of above types.

Q5. Short Notes

(i) Virtual Function
Used for runtime polymorphism — ensures that the derived class function is invoked via base class pointer.

(ii) Function Template
Generic function that works with multiple data types:

 

template <class T> T add(T a, T b) { return a + b; }

Summary

This Object-Oriented Programming with C++ (CS403) paper thoroughly tests:

TopicCore Concepts
OOP FundamentalsAbstraction, encapsulation, inheritance, polymorphism
Functions & OperatorsOverloading, inline, virtual functions
Classes & ObjectsConstructors, destructors, copy constructor
Templates & FilesGeneric programming and file I/O
Error HandlingException handling and robustness

 

ofstream fout("data.txt"); fout << "Hello World!"; fout.close(); ifstream fin("data.txt"); string s; fin >> s; cout << s; fin.close();

 

try {  int x = 5, y = 0;  if(y == 0) throw "Divide by zero!";  cout << x / y; } catch(const char* msg) {  cout << msg; }

 

class Complex {  int r, i; public:  Complex(int a, int b) { r = a; i = b; }  Complex operator+(Complex c) {    return Complex(r + c.r, i + c.i);  } };

 

void print(int a);   void print(double a);

 

class Demo {  int x; public:  Demo(int a) { x = a; }  Demo(Demo &d) { x = d.x; } // copy constructor };

File Size
50.4 KB
Uploader
SuGanta International
⭐ Elite Educators Network

Meet Our Exceptional Teachers

Discover passionate educators who inspire, motivate, and transform learning experiences with their expertise and dedication

KISHAN KUMAR DUBEY

KISHAN KUMAR DUBEY

Sant Ravidas Nagar Bhadohi, Uttar Pradesh , Babusarai Market , 221314
5 Years
Years
₹10000+
Monthly
₹201-300
Per Hour

This is Kishan Kumar Dubey. I have done my schooling from CBSE, graduation from CSJMU, post graduati...

Swethavyas bakka

Swethavyas bakka

Hyderabad, Telangana , 500044
10 Years
Years
₹10000+
Monthly
₹501-600
Per Hour

I have 10+ years of experience in teaching maths physics and chemistry for 10th 11th 12th and interm...

Vijaya Lakshmi

Vijaya Lakshmi

Hyderabad, Telangana , New Nallakunta , 500044
30+ Years
Years
₹9001-10000
Monthly
₹501-600
Per Hour

I am an experienced teacher ,worked with many reputed institutions Mount Carmel Convent , Chandrapu...

Shifna sherin F

Shifna sherin F

Gudalur, Tamilnadu , Gudalur , 643212
5 Years
Years
₹6001-7000
Monthly
₹401-500
Per Hour

Hi, I’m Shifna Sherin! I believe that every student has the potential to excel in Math with the righ...

Divyank Gautam

Divyank Gautam

Pune, Maharashtra , Kothrud , 411052
3 Years
Years
Not Specified
Monthly
Not Specified
Per Hour

An IIT graduate having 8 years of experience teaching Maths. Passionate to understand student proble...

Explore Tutors In Your Location

Discover expert tutors in popular areas across India

Prenatal Yoga Training Near Uppal Southend, Gurugram – A Calm & Healthy Pregnancy Journey Uppal Southend, Gurugram
SEO Training Classes Near Kirti Nagar – Master Search Engine Optimization Kirti Nagar, Delhi
Home Tuition (All Subjects) Near Sector 88 Gurugram – Personalized Learning for Academic Excellence Sector 88, Gurugram
Real Estate Consulting Near By Dwarka Mor Professional Property Guidance for Buying, Selling & Investment Decisions Dwarka Mor, Delhi
Spoken English Classes Near By Vasant Vihar Improve Fluency, Build Confidence & Achieve Career Success in 2026 Vasant Vihar, Delhi
Zumba Classes Near Palam Vihar – Fun Dance Fitness for a Healthy Lifestyle Palam Vihar, Gurugram
Spoken English Classes Near By Green Park Build Fluency, Confidence & Professional Communication Skills in 2026 Green Park, Delhi
Harmonium Classes Near Sector 141 – Learn Classical & Devotional Music Professionally Noida
Spoken English Classes Near By Punjabi Bagh Improve Fluency, Build Confidence & Unlock Career Opportunities in 2026 Punjabi Bagh, Delhi
Public Speaking Training Near Sector 108 Noida – Build Confidence and Communication Skills Noida
Personality Development Classes Near Uttam Nagar – Build Confidence & Leadership Skills Uttam Nagar, Delhi
No Office Rent Business Setup Near Najafgarh Start & Grow Your Business Without Paying High Office Rent in 2026 Najafgarh, Delhi
Spoken English Classes Near By Subhash Nagar Improve Fluency, Build Confidence & Unlock Career Opportunities in 2026 Subhash Nagar, Delhi
Music Theory & Composition Classes Near By Najafgarh – Build Your Musical Foundation Najafgarh, Delhi
Violin Classes Near DLF Phase 5 – Learn, Grow & Perform with Confidence DLF Phase V, Gurugram
Spoken English Classes Near By Hauz Khas Build Fluency, Confidence & Professional Communication Skills in 2026 Hauz Khas, Delhi
Digital Marketing Classes Near Noida Sector 98 – Learn Modern Marketing Skills and Build a Successful Career Expressway, Sector 98, Noida, Noida
Spoken English Classes Near By CR Park Improve Fluency, Boost Confidence & Unlock Better Opportunities in 2026 Chittaranjan Park, Delhi
Drum Lessons Near DLF Phase 4 – Learn Drumming with Electronic Drum Training at Home DLF Phase IV, Gurugram
Spoken English Classes Near Khanna Market By Improve Fluency, Build Confidence & Unlock Global Opportunities in 2026 Khanna Market, Delhi
⭐ Premium Institute Network

Discover Elite Educational Institutes

Connect with top-tier educational institutions offering world-class learning experiences, expert faculty, and innovative teaching methodologies

Réussi Academy of languages

sugandha mishra

Réussi Academy of languages
Madhya pradesh, Indore, G...

Details

Coaching Center
Private
Est. 2021-Present

Sugandha Mishra is the Founder Director of Réussi Academy of Languages, a premie...

IGS Institute

Pranav Shivhare

IGS Institute
Uttar Pradesh, Noida, Sec...

Details

Coaching Center
Private
Est. 2011-2020

Institute For Government Services

Krishna home tutor

Krishna Home tutor

Krishna home tutor
New Delhi, New Delhi, 110...

Details

School
Private
Est. 2001-2010

Krishna home tutor provide tutors for all subjects & classes since 2001

Edustunt Tuition Centre

Lakhwinder Singh

Edustunt Tuition Centre
Punjab, Hoshiarpur, 14453...

Details

Coaching Center
Private
Est. 2021-Present
Great success tuition & tutor

Ginni Sahdev

Great success tuition & tutor
Delhi, Delhi, Raja park,...

Details

Coaching Center
Private
Est. 2011-2020