PYQs

Object Oriented Programming using C++

5 papers · 100313

2022100313

B.Tech 3rd Semester Examination, 2022

03 Hours70 marks

Instructions

  • The marks are indicated in the right-hand margin.
  • There are NINE questions in this paper.
  • Attempt FIVE questions in all.
  • Question No. 1 is compulsory.

Q.1 Choose the correct answer of the following (Any seven question only):

Ask AI
  1. Q1.1

    Which of the following is not a type of class?

    a)

    Abstract class

    b)

    Final class

    c)

    Start class

    d)

    String class

    Ask AI
  2. Q1.2

    Which among the following best describes the inheritance?

    a)

    copying the code already written

    b)

    using the code already written once.

    c)

    using already defined functions in programming language

    d)

    using the data and functions into derived segment.

    Ask AI
  3. Q1.3

    What is the default access specifier for data members or member functions within a class without any specifier in C++?

    a)

    Private

    b)

    Protected

    c)

    Public

    d)

    Depends on compiler

    Ask AI
  4. Q1.4

    Which of the following is not the member of class?

    a)

    Static function

    b)

    Friend function

    c)

    Constant function

    d)

    Virtual function

    Ask AI
  5. Q1.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;

    a)

    Default constructor

    b)

    Parameterized constructor

    c)

    Compile time error

    d)

    Run-time error

    Ask AI
  6. Q1.6

    To prevent any method from overriding, we declare the method as

    a)

    Static

    b)

    const

    c)

    final

    d)

    None of the above

    Ask AI
  7. Q1.7

    In C++ dynamic memory allocation is accomplished with the operator:

    a)

    new

    b)

    this

    c)

    malloc

    d)

    delete

    Ask AI
  8. Q1.8

    When a class serves as base class for many derived classes, the situation is called

    a)

    polymorphism

    b)

    hierarchical inheritance

    c)

    hybrid inheritance

    d)

    multipath inheritance

    Ask AI
  9. Q1.9

    For a method to be an interface between the outside world and a class, it must be declared

    a)

    private

    b)

    protected

    c)

    public

    d)

    external

    Ask AI
  10. Q1.10

    Which of the following statement is correct?

    a)

    Base class pointer cannot point to derived class

    b)

    Derived class pointer cannot point to base class.

    c)

    Pointer to derived class cannot be created

    d)

    Pointer to base class cannot be created.

    Ask AI

Q.2 Solve both questions :

Ask AI
  1. Q2.1

    What are the advantages of using exception handling mechanism in a program? Explain the uses of try, throw and catch keywords using example.

    Ask AI
  2. Q2.2

    Write a C++ program to find the sum of the series $ 1+3+5+......+n $.

    Ask AI

Q.3 Solve both questions :

Ask AI
  1. Q3.1

    What is inheritance? Discuss different types of inheritance with examples.

    Ask AI
  2. Q3.2

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

    Ask AI

Q.4 Solve both questions :

Ask AI
  1. Q4.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.

    Ask AI
  2. Q4.2

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

    Ask AI

Q.5 Solve both questions :

Ask AI
  1. Q5.1

    Differentiate between abstract class and interface with suitable examples.

    Ask AI
  2. Q5.2

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

    Ask AI

Q.6 Solve both questions :

Ask AI
  1. Q6.1

    Differentiate between a class and an object. Write an example (syntax) to define a class in C++.

    Ask AI
  2. Q6.2

    With an example, explain the terms constructor and destructor.

    Ask AI

Q.7 Solve both questions :

Ask AI
  1. Q7.1

    What is a friend function and what are its advantages? What are the guidelines that should be followed while using friend function?

    Ask AI
  2. Q7.2

    Explain dangling pointer with the help of an example.

    Ask AI

Q.8 Solve both questions :

Ask AI
  1. Q8.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.

    Ask AI
  2. Q8.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.

    Ask AI

Q.9 Write short notes on any two of the following:

Ask AI
  1. Q9.1

    a)

    Polymorphism

    b)

    Function Templates

    c)

    Container class

    d)

    Inline function

    Ask AI

2022V4100313

B.Tech 3rd Semester Examination, 2022

03 Hours70 marks

Instructions

  • The marks are indicated in the right-hand margin.
  • There are NINE questions in this paper.
  • Attempt FIVE questions in all.
  • Question No. 1 is compulsory.

Q.1 Choose the correct answer of the following (Any seven question only):

Ask AI
  1. Q1.1

    Which of the following is not a type of class?

    a)

    Abstract class

    b)

    Final class

    c)

    Start class

    d)

    String class

    Ask AI
  2. Q1.2

    Which among the following best describes the inheritance?

    a)

    copying the code already written

    b)

    using the code already written once.

    c)

    using already defined functions in programming language

    d)

    using the data and functions into derived segment.

    Ask AI
  3. Q1.3

    What is the default access specifier for data members or member functions within a class without any specifier in C++?

    a)

    Private

    b)

    Protected

    c)

    Public

    d)

    Depends on compiler

    Ask AI
  4. Q1.4

    Which of the following is not the member of class?

    a)

    Static function

    b)

    Friend function

    c)

    Constant function

    d)

    Virtual function

    Ask AI
  5. Q1.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;

    a)

    Default constructor

    b)

    Parameterized constructor

    c)

    Compile time error

    d)

    Run-time error

    Ask AI
  6. Q1.6

    To prevent any method from overriding, we declare the method as

    a)

    Static

    b)

    const

    c)

    final

    d)

    None of the above

    Ask AI
  7. Q1.7

    In C++ dynamic memory allocation is accomplished with the operator:

    a)

    new

    b)

    this

    c)

    malloc

    d)

    delete

    Ask AI
  8. Q1.8

    When a class serves as base class for many derived classes, the situation is called

    a)

    polymorphism

    b)

    hierarchical inheritance

    c)

    hybrid inheritance

    d)

    multipath inheritance

    Ask AI
  9. Q1.9

    For a method to be an interface between the outside world and a class, it must be declared

    a)

    private

    b)

    protected

    c)

    public

    d)

    external

    Ask AI
  10. Q1.10

    Which of the following statement is correct?

    a)

    Base class pointer cannot point to derived class

    b)

    Derived class pointer cannot point to base class.

    c)

    Pointer to derived class cannot be created

    d)

    Pointer to base class cannot be created.

    Ask AI

Q.2 Solve both questions :

Ask AI
  1. Q2.1

    What are the advantages of using exception handling mechanism in a program? Explain the uses of try, throw and catch keywords using example.

    Ask AI
  2. Q2.2

    Write a C++ program to find the sum of the series $ 1+3+5+......+n $.

    Ask AI

Q.3 Solve both questions :

Ask AI
  1. Q3.1

    What is inheritance? Discuss different types of inheritance with examples.

    Ask AI
  2. Q3.2

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

    Ask AI

Q.4 Solve both questions :

Ask AI
  1. Q4.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.

    Ask AI
  2. Q4.2

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

    Ask AI

Q.5 Solve both questions :

Ask AI
  1. Q5.1

    Differentiate between abstract class and interface with suitable examples.

    Ask AI
  2. Q5.2

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

    Ask AI

Q.6 Solve both questions :

Ask AI
  1. Q6.1

    Differentiate between a class and an object. Write an example (syntax) to define a class in C++.

    Ask AI
  2. Q6.2

    With an example, explain the terms constructor and destructor.

    Ask AI

Q.7 Solve both questions :

Ask AI
  1. Q7.1

    What is a friend function and what are its advantages? What are the guidelines that should be followed while using friend function?

    Ask AI
  2. Q7.2

    Explain dangling pointer with the help of an example.

    Ask AI

Q.8 Solve both questions :

Ask AI
  1. Q8.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.

    Ask AI
  2. Q8.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.

    Ask AI

Q.9 Write short notes on any two of the following:

Ask AI

2020100313

B.Tech 3rd Semester Exam., 2020

03 Hours70 marks

Instructions

  • The marks are indicated in the right-hand margin.
  • There are NINE questions in this paper.
  • Attempt FIVE questions in all.
  • Question No. 1 is compulsory.

Q.1 Answer any seven parts:

Ask AI
  1. Q1.1

    Write the name of the function in C++ used for opening a file for input only.

    Ask AI
  2. Q1.2

    What is the purpose of using a derived class?

    Ask AI
  3. Q1.3

    Is there any difference between public protection and private protection?

    Ask AI
  4. Q1.4

    How does abstract class differ from interface?

    Ask AI
  5. Q1.5

    What is the role of catch block in the exception handling?

    Ask AI
  6. Q1.6

    Is it possible to return more than one value from a function? Explain with a small example.

    Ask AI
  7. Q1.7

    What are the mutator functions? Give an example.

    Ask AI
  8. Q1.8

    Discuss the role of default constructor when an object of a class is created.

    Ask AI
  9. Q1.9

    Write a small code which illustrates the concept of multiple inheritance.

    Ask AI
  10. Q1.10

    Differentiate between compile-time polymorphism and run-time polymorphism.

    Ask AI

Q.2 Solve both questions :

Ask AI
  1. Q2.1

    Write a language program in C++ which accepts the user's first and last name and print them in reverse order with a space between them.

    Ask AI
  2. Q2.2

    Create the equivalent of a four-function calculator. The program should ask the user to enter a number, an operator and another number. (Use floating point.) It should then carry out the specified arithmetical operation: adding, subtracting, multiplying or dividing the two numbers. Use a switch statement to select the operation. Finally, display the result. When it finishes the calculation, the program should ask whether the user wants to do another calculation. The response can be 'y' or 'n'.

    Ask AI

Q.3 Solve both questions :

Ask AI
  1. Q3.1

    Use a single-subscripted array to solve the following problem: Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it is not a duplicate of a number already read. Provide for the 'worst case' in which all 20 numbers are different. Use the smallest possible array to solve this problem.

    Ask AI
  2. Q3.2

    Write a program in C++ to read text file and display count of character in file.

    Ask AI

Q.4 Solve both questions :

Ask AI
  1. Q4.1

    What is the main advantage of passing arguments by reference? When do we need to use default arguments in a function?

    Ask AI
  2. Q4.2

    What do you mean by dynamic binding? How is it useful in OOP?

    Ask AI

Q.5 Solve both questions :

Ask AI
  1. Q5.1

    What is constructor? Write a program in C++ to find the area of the circle using constructor.

    Ask AI
  2. Q5.2

    Define a class to represent a bank account. Include the following members:
    Data members: 1. Name of the depositor 2. Account number 3. Type of account 4. Balance amount in the account
    Member functions: 1. To assign initial values 2. To deposit an amount 3. To withdraw an amount after checking the balance 4. To display name and balance.
    Write a main program which handles 10 customers.

    Ask AI

Q.6 Solve both questions :

Ask AI
  1. Q6.1

    What do you mean by dynamic initialization of objects? Why do we need to do this? How is dynamic initialization of objects achieved?

    Ask AI
  2. Q6.2

    Write a C++ program to define a class string and use overloaded == operator to compare two strings.

    Ask AI

Q.7 Solve both questions :

Ask AI
  1. Q7.1

    Some programmers prefer not to use protected access because it breaks the encapsulation of the base class. Discuss the relative merits of using protected access vs. insisting on using private access in base classes.

    Ask AI
  2. Q7.2

    Write a C++ program to demonstrate example of hierarchical inheritance to get square and cube of a number.

    Ask AI

Q.8 Solve both questions :

Ask AI
  1. Q8.1

    We knew that a private member of a base class is not inheritable. Is it anyway possible for the objects of a derived class to access the private members of the base class? If yes, how?

    Ask AI
  2. Q8.2

    Write a program that uses a function template called max to determine the largest of three arguments. Test the program using integer, character and floating-point number pairs.

    Ask AI

Q.9 Solve both questions :

Ask AI
  1. Q9.1

    Describe the relationship between class templates and inheritance. Why is it appropriate to call a class template a parameterized type?

    Ask AI
  2. Q9.2

    Write a program that demonstrates how certain exception types are not allowed to be thrown.

    Ask AI

2020SPECIAL100313

B.Tech 3rd Semester Special Exam., 2020

03 Hours70 marks

Instructions

  • The marks are indicated in the right-hand margin.
  • There are NINE questions in this paper.
  • Attempt FIVE questions in all.
  • Question No. 1 is compulsory.

Q.1 Answer any seven of the following questions:

Ask AI
  1. Q1.1

    How void pointers differ from general pointers?

    Ask AI
  2. Q1.2

    Is it possible to access data without any member function in the class? Justify your reason.

    Ask AI
  3. Q1.3

    How precedence of operators effects evaluation of an expression?

    Ask AI
  4. Q1.4

    Write the advantage of object-oriented programming over procedural programming.

    Ask AI
  5. Q1.5

    Why we generally avoid goto in the programming?

    Ask AI
  6. Q1.6

    What is the role of try block in the exception handling?

    Ask AI
  7. Q1.7

    Write the difference between class and structure.

    Ask AI
  8. Q1.8

    What is the use of scope resolution operator?

    Ask AI
  9. Q1.9

    Why we require derive data types in the programming when we already have different data types?

    Ask AI
  10. Q1.10

    Write a small code which illustrates the concept of multilevel inheritance.

    Ask AI

Q.2 Solve both questions :

Ask AI
  1. Q2.1

    On a certain day the British pound was equivalent to $1.487 US, the French franc was $0.172, the German deutschemark was $0.584, and the Japanese yen was $0.00955. Write a program in C++ that allows the user to enter an amount in dollars, and then displays this value converted to these four other monetary units.

    Ask AI
  2. Q2.2

    What are command line arguments? Write a program in C++ to finding factorial for a given number using command line argument.

    Ask AI

Q.3 Solve both questions :

Ask AI
  1. Q3.1

    What is a principal reason for passing arguments by reference? Write a function called zeroSmaller() that is passed two int arguments by reference and then sets the smaller of the two numbers to 0. Write a main() program to exercise this function.

    Ask AI
  2. Q3.2

    Write a C++ program to which replace all the words "dog" with "cat".

    Ask AI

Q.4 Solve both questions :

Ask AI
  1. Q4.1

    Compare and contrast dynamic memory allocation using the C++ operators new and delete, with dynamic memory allocation using the C standard library functions malloc and free.

    Ask AI
  2. Q4.2

    Write programs to evaluate the following function to 0.0001% accuracy:
    $ SUM = 1 + \left(\frac{1}{2}\right)^{2} + \left(\frac{1}{3}\right)^{3} + \left(\frac{1}{4}\right)^{4} + \dots $

    Ask AI

Q.5 Solve both questions :

Ask AI
  1. Q5.1

    Create a class Rectangle. The class has attributes length and width, each of which defaults to 1. It has member functions that calculate the perimeter and the area of the rectangle. It has set and get functions for both length and width. The set functions should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0.

    Ask AI
  2. Q5.2

    Assume that there is a class Derv that is derived from a base class Base. Write the decelerator for a derived-class constructor that takes one argument and passes this argument along to the constructor in the base class.

    Ask AI

Q.6 Solve both questions :

Ask AI
  1. Q6.1

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

    Ask AI
  2. Q6.2

    A friend function cannot be used to overload the assignment operator =. Explain why.

    Ask AI

Q.7 Solve both questions :

Ask AI
  1. Q7.1

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

    Ask AI
  2. Q7.2

    What is a virtual function? Why we need virtual functions?

    Ask AI

Q.8 Solve both questions :

Ask AI
  1. Q8.1

    What are the different forms of inheritance? Give an example for each.

    Ask AI
  2. Q8.2

    Write a program that uses a function template called min to determine the smaller of two arguments. Test the program using integer, character and floating-point number pairs.

    Ask AI

Q.9 Solve both questions :

Ask AI
  1. Q9.1

    What is the relationship between function templates and overloading? Explain with the help of an example

    Ask AI
  2. Q9.2

    What are the advantages of using exception handling mechanism in a program? Explain with an example.

    Ask AI

2020V4100313

B.Tech 3rd Semester Exam., 2020

03 Hours70 marks

Instructions

  • The marks are indicated in the right-hand margin.
  • There are NINE questions in this paper.
  • Attempt FIVE questions in all.
  • Question No. 1 is compulsory.

Q.1 Answer any seven parts:

Ask AI
  1. Q1.1

    Write the name of the function in C++ used for opening a file for input only.

    Ask AI
  2. Q1.2

    What is the purpose of using a derived class?

    Ask AI
  3. Q1.3

    Is there any difference between public protection and private protection?

    Ask AI
  4. Q1.4

    How does abstract class differ from interface?

    Ask AI
  5. Q1.5

    What is the role of catch block in the exception handling?

    Ask AI
  6. Q1.6

    Is it possible to return more than one value from a function? Explain with a small example.

    Ask AI
  7. Q1.7

    What are the mutator functions? Give an example.

    Ask AI
  8. Q1.8

    Discuss the role of default constructor when an object of a class is created.

    Ask AI
  9. Q1.9

    Write a small code which illustrates the concept of multiple inheritance.

    Ask AI
  10. Q1.10

    Differentiate between compile-time polymorphism and run-time polymorphism.

    Ask AI

Q.2 Solve both questions :

Ask AI
  1. Q2.1

    Write a language program in C++ which accepts the user's first and last name and print them in reverse order with a space between them.

    Ask AI
  2. Q2.2

    Create the equivalent of a four-function calculator. The program should ask the user to enter a number, an operator and another number. (Use floating point.) It should then carry out the specified arithmetical operation: adding, subtracting, multiplying or dividing the two numbers. Use a switch statement to select the operation. Finally, display the result. When it finishes the calculation, the program should ask whether the user wants to do another calculation. The response can be 'y' or 'n'.

    Ask AI

Q.3 Solve both questions :

Ask AI
  1. Q3.1

    Use a single-subscripted array to solve the following problem: Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it is not a duplicate of a number already read. Provide for the 'worst case' in which all 20 numbers are different. Use the smallest possible array to solve this problem.

    Ask AI
  2. Q3.2

    Write a program in C++ to read text file and display count of character in file.

    Ask AI

Q.4 Solve both questions :

Ask AI
  1. Q4.1

    What is the main advantage of passing arguments by reference? When do we need to use default arguments in a function?

    Ask AI
  2. Q4.2

    What do you mean by dynamic binding? How is it useful in OOP?

    Ask AI

Q.5 Solve both questions :

Ask AI
  1. Q5.1

    What is constructor? Write a program in C++ to find the area of the circle using constructor.

    Ask AI
  2. Q5.2

    Define a class to represent a bank account. Include the following members:
    Data members: 1. Name of the depositor 2. Account number 3. Type of account 4. Balance amount in the account
    Member functions: 1. To assign initial values 2. To deposit an amount 3. To withdraw an amount after checking the balance 4. To display name and balance.
    Write a main program which handles 10 customers.

    Ask AI

Q.6 Solve both questions :

Ask AI
  1. Q6.1

    What do you mean by dynamic initialization of objects? Why do we need to do this? How is dynamic initialization of objects achieved?

    Ask AI
  2. Q6.2

    Write a C++ program to define a class string and use overloaded == operator to compare two strings.

    Ask AI

Q.7 Solve both questions :

Ask AI
  1. Q7.1

    Some programmers prefer not to use protected access because it breaks the encapsulation of the base class. Discuss the relative merits of using protected access vs. insisting on using private access in base classes.

    Ask AI
  2. Q7.2

    Write a C++ program to demonstrate example of hierarchical inheritance to get square and cube of a number.

    Ask AI

Q.8 Solve both questions :

Ask AI
  1. Q8.1

    We knew that a private member of a base class is not inheritable. Is it anyway possible for the objects of a derived class to access the private members of the base class? If yes, how?

    Ask AI
  2. Q8.2

    Write a program that uses a function template called max to determine the largest of three arguments. Test the program using integer, character and floating-point number pairs.

    Ask AI

Q.9 Solve both questions :

Ask AI
  1. Q9.1

    Describe the relationship between class templates and inheritance. Why is it appropriate to call a class template a parameterized type?

    Ask AI
  2. Q9.2

    Write a program that demonstrates how certain exception types are not allowed to be thrown.

    Ask AI

Support BEUConnect

Contributions cover the domain and hosting.

UPI QR code for pritkr@cnrb
pritkr@cnrb

Add to home screen

  1. Tap Share in Safari.
  2. Choose Add to Home Screen.