Logo

BIT Object Oriented Programming

bitsemester 2

Object Oriented Programming

Subject Code: BIT153

Course Title: Object Oriented Programming

Course No: BIT153

Nature of Course: Theory & Practical

Full Marks: 100

Pass Marks: 40

Credit Hours: 3

Course Description

The course familiarizes students with the concepts of object oriented programming using C++.

Course Objective

The main objective of this course is to understand the basics of object oriented programming. This course covers the C++ concepts such as objects, class, operator overloading, inheritance and polymorphism, file I/O, exception handling and templates.

Course Contents

Unit Teaching Methodology Teaching Hours
Unit 1: Introduction to Object Oriented Programming (3 Hrs.)
1.1 Overview of structured and object oriented programming approach, Characteristics of object oriented languages: Object, Class, Data Abstraction, Encapsulation, Inheritance, Polymorphism, Dynamic Binding, and Message Passing. Lecture 3
Unit 2: Basics of C++ programming (5 Hrs.)
2.1 C++ Program Structure, Character Set and Tokens, Data Types, Type Conversion, Preprocessor Directives, Namespace, Input/Output Streams (cin and cout object, Cascading of IO Operators) Manipulators (endl, setw, and setprecision), Dynamic Memory Allocation with new and delete, Review of Control Statements. Lecture + Laboratory Work 2
2.2 Functions: Function Overloading, Inline Functions, Default Argument, Pass by Reference, Return by Reference, Scope and Storage Class. 2
2.3 Pointers: Review of Pointer variables declaration & initialization, Operators in pointers/Pointer Arithmetic, Pointers and Arrays, Pointer and Function. 1
Unit 3: Class and Objects (10 Hrs.)
3.1 Structures and Classes, Class and Object, Accessing members of class, Memory allocation for Objects, Defining Member functions of the class (inside and outside the class). Lecture + Laboratory Work 3
3.2 Initialization of class object (Constructor), Destructor, Types of Constructor (Default Constructor, Parameterized Constructor, Copy Constructor, The Default Copy Constructor). 3
3.3 Objects as Function Arguments, Returning Objects from Functions, Static members (Static data members and static member functions). 2
3.4 Friend Function and Friend Class, Copy Initialization, This Pointer. 2
Unit 4: Operator Overloading (7 Hrs.)
4.1 Fundamental of operator overloading, Restriction on operator overloading (operators that cannot be overloaded), Rules for Overloading Operators. Operator functions as a class members. Lecture + Laboratory Work 1
4.2 Overloading unary Operators: Overloading Pre-increment, Post-increment, and Negation Operator. 2
4.3 Overloading Binary Operators: Overloading Plus Operator, Overloading Comparison Operator, String Concatenation using operator overloading. 2
4.4 Data Conversion: Basic to User-defined/class, User-defined/class to Basic, User-defined/class to User-defined/class. 2
Unit 5: Inheritance (7 Hrs.)
5.1 Introduction to inheritance, Derived Class and Base Class, Access Specifiers (private, protected, and public). Lecture + Laboratory Work 1.5
5.2 Types/Forms of inheritance (Single, Multiple, Hierarchical, Multilevel, Hybrid), Public, Protected and Private Inheritance. 2.5
5.3 Constructor and Destructor in derived classes (Order of execution of Constructors and Destructors). 1
5.4 Aggregation, Aggregation vs. Inheritance, Ambiguity (Ambiguity in Multiple and Multipath Inheritance), Virtual Base Class. 2
Unit 6: Virtual Function, Polymorphism, and other C++ Features (3 Hrs.)
6.1 Concept of Static and Dynamic Polymorphism, Pointers to Base Class, Concept of Virtual functions, Implementation of Dynamic Polymorphism, Abstract class, Concrete Class, Pure Virtual Functions, Virtual Destructors, Roles of Polymorphism. Lecture + Laboratory Work 3
Unit 7: Function Templates and Exception Handling (4 Hrs.)
7.1 Templates: Introduction, Function Templates, Function templates with multiple arguments, Class Templates, Templates and Inheritance, Rules for Using Templates. Lecture + Laboratory Work 2
7.2 Exception Handling: Introduction, Mechanism of Exception Handling, Try, catch and throw statements, Multiple Catch Statement, Catching All Exceptions, Uses of exception handling. 2
Unit 8: File and Streams (6 Hrs.)
8.1 Stream Class Hierarchy, File pointers (Read and Write Pointer), Reading and Writing Text Files, Detecting end of file, Reading and Writing Binary Files. Lecture + Laboratory Work 4
8.2 Reading and Writing Objects, Random File Access. 2

Model Question

Course Title: Object Oriented Programming | Full Marks: 60 Course No: BIT153 | Pass Marks: 24 Time: 3 Hrs. | Semester: II

Section A

Attempt ANY TWO {10 × 2 = 20}

  1. Write a program to create a class Customer with data members customer Id, Name, and age. Put member functions to read and display values of data members. Also define constructors to initialize data members with default value. Finally create object to read and display data of 10 customers.
  2. Create a class Employee with private data members Eid, Ename, and Salary. Include public member functions to read and display value of data members. Derive a class named Typist from above class. The class should contain a private data member typing_speed and public member functions to read and display values of data members. Finally create two objects of typist class and read and display their values.
  3. What are the different ways of achieving static polymorphism? Discuss overloading of pre-increment and post-increment operators with suitable examples.

Section B

Attempt ANY EIGHT {5 × 8 = 40}

  1. What is meant by default argument? Explain with suitable example.
  2. What are the uses of this pointer? Discuss its concept with suitable example.
  3. What is destructor? Discuss its characteristics with suitable example.
  4. Write a program to convert floating point value to object of distance class with data members feet and inch.
  5. How late binding differs from early binding? How can you achieve dynamic polymorphism? Explain with example.
  6. What is meant by ambiguity? Explain ambiguity in multiple inheritance and its solution with example.
  7. Write a program to handle "array index out of range" exception.
  8. Why concept of templates is important? Explain function templates with example.
  9. Write a program to read text from keyboard and write it to a file named "test.txt". Again read the content of file and display it in the monitor.

Text Books

Robert Lafore, Object Oriented Programming in C++, Fourth Edition, SAMS Publications.

Reference Books

  • Deitel and Deitel, C++ How to Program, Third Edition, Pearson Publication.
  • Joyce Farrell, Object-Oriented Programming Using C++, Fourth Edition, Cengage Learning.
  • Herbert Schildt, C++ The Complete Reference, Fourth Edition, Tata McGraw Hill Publication.
  • E. Balagurusamy, "Object Oriented Programming With C++", 7th Edition, McGraw Hill India.
  • A. S. Saud, "C++ Programming with Object Oriented Approach", 2nd Edition, KEC Publication and Distributor.

Lab Works

Lab Manual

Lab Sheet # Chapter Activities
Lab Sheet #1 Chapter 2 1. Write programs to demonstrate insertion & extraction operators, manipulators, and dynamic memory management.<br>2. Write programs to demonstrate default arguments, inline function, and function overloading.
Lab Sheet #2 Chapter 3 1. Write programs to demonstrate class, object, array of objects, and pointer objects.<br>2. Write programs to demonstrate constructor and destructor.<br>3. Write programs to demonstrate static members, this pointer, friend function, and friend class.
Lab Sheet #3 Chapter 4 1. Write programs to demonstrate unary operator overloading.<br>2. Write programs to demonstrate binary operator overloading.<br>3. Write programs to demonstrate type conversions.
Lab Sheet #4 Chapter 5 1. Write programs to demonstrate access specifiers and different types of inheritances.<br>2. Write programs to demonstrate constructor and destructors in inheritance.<br>3. Write programs to demonstrate public and private derivation.<br>4. Write programs to demonstrate ambiguities and inheritance and their solution.
Lab Sheet #5 Chapter 6 1. Write programs to demonstrate run time polymorphism.
Lab Sheet #6 Chapter 7 1. Write programs to demonstrate function and class templates.<br>2. Write programs to demonstrate try, catch, and throw statements.<br>3. Write programs to demonstrate multiple catch blocks.
Lab Sheet #7 Chapter 8 1. Write programs to demonstrate reading and writing text and binary files.<br>2. Write programs to demonstrate reading and writing objects.<br>3. Write programs to demonstrate random access in files.