Object Oriented Programming using C++ - B.Tech 3rd Semester Examination, 2022

2022Semester 2Civil-CAEnd Semester
Bihar Engineering University, Patna
B.Tech 3rd Semester Examination, 2022

Object Oriented Programming using C++

Time: 03 HoursCode: 100313Full 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 answer of the following (Any seven question only):[14]
  1. Which of the following is not a type of class?

    1. Abstract class
    2. Final class
    3. Start class
    4. String class
  2. Which among the following best describes the inheritance?

    1. copying the code already written
    2. using the code already written once.
    3. using already defined functions in programming language
    4. using the data and functions into derived segment.
  3. What is the default access specifier for data members or member functions within a class without any specifier in C++?

    1. Private
    2. Protected
    3. Public
    4. Depends on compiler
  4. Which of the following is not the member of class?

    1. Static function
    2. Friend function
    3. Constant function
    4. Virtual function
  5. Which constructor will be called from the object created in the code below?

    Class A { int i; A() { \( i=0 \); } A (int \( x=0 \)) { \( i=x; \) } }; A obj1;

    1. Default constructor
    2. Parameterized constructor
    3. Compile time error
    4. Run-time error
  6. To prevent any method from overriding, we declare the method as

    1. Static
    2. const
    3. final
    4. None of the above
  7. In C++ dynamic memory allocation is accomplished with the operator:

    1. new
    2. this
    3. malloc
    4. delete
  8. When a class serves as base class for many derived classes, the situation is called

    1. polymorphism
    2. hierarchical inheritance
    3. hybrid inheritance
    4. multipath inheritance
  9. For a method to be an interface between the outside world and a class, it must be declared

    1. private
    2. protected
    3. public
    4. external
  10. Which of the following statement is correct?

    1. Base class pointer cannot point to derived class
    2. Derived class pointer cannot point to base class.
    3. Pointer to derived class cannot be created
    4. Pointer to base class cannot be created.
Q.2 Solve both questions :[14]
  1. What are the advantages of using exception handling mechanism in a program? Explain the uses of try, throw and catch keywords using example.

  2. Write a C++ program to find the sum of the series \( 1+3+5+......+n \).

Q.3 Solve both questions :[14]
  1. What is inheritance? Discuss different types of inheritance with examples.

  2. What is operator overloading? Write a program in C++ to overload unary minus operator.

Q.4 Solve both questions :[14]
  1. What is pure virtual function? Write a C++ program that prints 'BEU Patna' from inside a member function of a subclass overriding a pure virtual function.

  2. Discuss why converting a base-class pointer to a derived-class pointer is considered dangerous by compiler.

Q.5 Solve both questions :[14]
  1. Differentiate between abstract class and interface with suitable examples.

  2. What is access modifier in C++? Differentiate between each type.

Q.6 Solve both questions :[14]
  1. Differentiate between a class and an object. Write an example (syntax) to define a class in C++.

  2. With an example, explain the terms constructor and destructor.

Q.7 Solve both questions :[14]
  1. What is a friend function and what are its advantages? What are the guidelines that should be followed while using friend function?

  2. Explain dangling pointer with the help of an example.

Q.8 Solve both questions :[14]
  1. Explain how base class member functions can be involved in a derived class if the derived class also has a member function with the same name.

  2. Crate a class complex and implement the following:
    (i) Define suitable constructors and destructors
    (ii) Overload the operators + and -
    (iii) Write a friend function sum which adds the real and imaginary parts of a complex object.

Q.9 Write short notes on any two of the following:[14]
    • Polymorphism
    • Function Templates
    • Container class
    • Inline function