Code: 100303Computer Science & Eng.3rd Semester5 Examination Papers

Object Oriented Programming using C++

Official Bihar Engineering University examination question papers, marks distribution, and questions transcript. Available exam sessions: 2024, 2022, 2020, 2013.

Exam Year:

Get Instant AI Answers on this Paper

Open BEU Connect Android app to solve any numerical or derive formulas step by step.

Ask AI in App
Official Exam Paper TranscriptB.Tech 3rd Semester Examination, 2024
Bihar Engineering University, Patna
B.Tech 3rd Semester Exam., 2024

OBJECT ORIENTED PROGRAMMING USING C++

Time: 03 HoursCode: 100313Semester: IIIFull Marks: 70

Instructions:

  1. The marks are indicated in the right-hand margin.
  2. There are NINE questions in this paper.
  3. Attempt FIVE questions in all.
  4. Question No. 1 is compulsory.
Q.1 Choose the correct option / answer the following (Any seven question only):[2 x 7 = 14]
  1. What is the default access specifier for class members in C++?

    1. public
    2. protected
    3. private
    4. internal
  2. What will be the output of the following code?

    #include <iostream>
    class Test {
    public:
       Test() { std::cout << "Constructor"; }
       ~Test() { std::cout << "Destructor"; }
    };
    int main() {
       Test t;
       return 0;
    }
    1. Constructor
    2. ConstructorDestructor
    3. Destructor
    4. DestructorConstructor
  3. What will be the output of the following code?

    #include <iostream>
    void display(int x) { std::cout << "Int"; }
    void display(double x) { std::cout << "Double"; }
    int main() {
       display(5.5f);
    }
    1. Int
    2. Float
    3. Double
    4. Error
  4. What is the output of the following code snippet?

    int arr[] = {1, 2, 3};
    int* p = arr;
    cout << *(p + 1);
    1. 1
    2. 3
    3. 2
    4. Error
  5. What is the output of the following code snippet?

    string s = "C++";
    s += " Rocks";
    cout << s;
    1. C++
    2. C++ Rocks
    3. Rocks
    4. Error
  6. Which of the following statement is incorrect?

    1. A static member function cannot be declared as virtual function
    2. Static and non-static functions with identical signatures cannot coexist in the same class in C++.
    3. A static member function cannot access the “this pointer”
    4. A non static member function can access only non static data members of a class.
  7. Identify the correct function template syntax.

    1. template function<T> void show(T t);
    2. function template<T> show(T t);
    3. template<class> show(T t);
    4. template<typename T> void show(T t);
  8. What will be the output of this code?

    #include <iostream>
    class Demo {
    public:
       void show() { std::cout << "Hello"; }
    };
    int main() {
       Demo d, *ptr = &d;
       ptr->show();
    }
    1. Hello
    2. Error
    3. show
    4. None
  9. What happens when a derived class object is assigned to a base class pointer?

    class Base { };
    class Derived : public Base { };
    int main() {
       Derived d;
       Base* b = &d;
    }
    1. Error
    2. Not allowed
    3. Requires template
    4. Upcasting; allowed
  10. What is the output of this code?

    #include <iostream>
    class A {
    public:
       ~A() { std::cout << "Destructor "; }
    };
    int main() {
       try {
          A a;
          throw 1;
       } catch (...) {
          std::cout << "Caught";
       }
    }
    1. Caught Destructor
    2. Destructor Caught
    3. Caught
    4. Error
Q.2[7+7=14]
  1. Explain the features of Object-Oriented Programming (OOP). How does OOP differ from the procedural programming paradigm? Also, list the advantages of using OOP in C++.

  2. Differentiate between while, do-while, and for loops in C++. Write a program to print the Fibonacci series using any loop. Hint: Fibonacci series: 0, 1, 1, 2, 3, 5, 8, 13, 21….

Q.3[7+7=14]
  1. Write a C++ program using function overloading to calculate the area of a square, rectangle, and circle using three overloaded area() functions. Demonstrate all three in main() and explain how function overloading works.

  2. Write a C++ program using the string class to input two strings, concatenate them, compare them, and find the length of the resulting string.

Q.4[7+7=14]
  1. Differentiate between a struct and a class in C++. Explain with examples how data hiding and default access specifiers differ between the two.

  2. Write a C++ program to define a class Account with data members like accountNumber, holderName, and balance. Include a default constructor to initialize default values, a parameterized constructor to assign specific values, and a destructor to display a message when the object is destroyed. In the main() function, create objects using both constructors. Also, briefly explain the role of constructors and destructors in C++.

Q.5[7+7=14]
  1. Write a program to overload the + operator to add two complex numbers using a class Complex. Also, discuss the rules and limitations of operator overloading.

  2. What is a function template in C++? Write a template function maximum() that returns the larger of two values. Demonstrate its use with integers, floats, and characters.

Q.6[7+7=14]
  1. What is a virtual base class in C++? Explain its role in resolving the diamond problem with an example involving classes A, B, C, and D, where D inherits from both B and C, and B and C inherit from A.

  2. Explain single and multiple inheritance in C++ with suitable examples. Write a program to demonstrate both types of inheritance. Also, discuss how ambiguity is handled in multiple inheritance.

Q.7[7+7=14]
  1. Write a C++ program to demonstrate the use of an abstract class with a pure virtual function. Explain how this supports runtime polymorphism.

  2. What is a void pointer in C++? Explain its use with an example. Also, demonstrate how a void pointer can be typecast to access different data types.

Q.8[7+7=14]
  1. Write a C++ program to demonstrate a pointer to a class and a pointer to an object. Create a class Student and use a pointer to access its member functions. Explain the concept of dynamic object access using pointers.

  2. Explain how arrays and pointers are related in C++. Write a program to process an array using pointers (e.g., calculate the sum of elements). Discuss pointer arithmetic with arrays.

Q.9[7+7=14]
  1. What is exception handling in C++? Explain the purpose and working of the try, throw, and catch keywords with proper syntax. Also, briefly explain the concept of stack unwinding in the context of exceptions.

  2. Write a program to handle division by zero using exception handling. Also, describe how control is transferred during an exception.

Related Official Syllabus

Check the complete official BEU syllabus for Computer Science & Eng. 3rd Semester to view credit allocations, recommended textbooks, and topics.

Open 3rd Semester Syllabus

Prepare Better with BEU Connect

  • Download papers for 100% offline study
  • Ask AI for step-by-step problem breakdown
  • Attempt official GATE CBT mock tests
  • Calculate SGPA and track attendance
Download Android App