Jump to Year/Set
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):
Which of the following is not a type of class?
Which among the following best describes the inheritance?
What is the default access specifier for data members or member functions within a class without any specifier in C++?
Which of the following is not the member of class?
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;
To prevent any method from overriding, we declare the method as
In C++ dynamic memory allocation is accomplished with the operator:
When a class serves as base class for many derived classes, the situation is called
For a method to be an interface between the outside world and a class, it must be declared
Which of the following statement is correct?
Q.2 Solve both questions :
What are the advantages of using exception handling mechanism in a program? Explain the uses of try, throw and catch keywords using example.
Write a C++ program to find the sum of the series $ 1+3+5+......+n $.
Q.3 Solve both questions :
What is inheritance? Discuss different types of inheritance with examples.
What is operator overloading? Write a program in C++ to overload unary minus operator.
Q.4 Solve both questions :
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.
Discuss why converting a base-class pointer to a derived-class pointer is considered dangerous by compiler.
Q.5 Solve both questions :
Differentiate between abstract class and interface with suitable examples.
What is access modifier in C++? Differentiate between each type.
Q.6 Solve both questions :
Differentiate between a class and an object. Write an example (syntax) to define a class in C++.
With an example, explain the terms constructor and destructor.
Q.7 Solve both questions :
What is a friend function and what are its advantages? What are the guidelines that should be followed while using friend function?
Explain dangling pointer with the help of an example.
Q.8 Solve both questions :
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.
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:
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):
Which of the following is not a type of class?
Which among the following best describes the inheritance?
What is the default access specifier for data members or member functions within a class without any specifier in C++?
Which of the following is not the member of class?
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;
To prevent any method from overriding, we declare the method as
In C++ dynamic memory allocation is accomplished with the operator:
When a class serves as base class for many derived classes, the situation is called
For a method to be an interface between the outside world and a class, it must be declared
Which of the following statement is correct?
Q.2 Solve both questions :
What are the advantages of using exception handling mechanism in a program? Explain the uses of try, throw and catch keywords using example.
Write a C++ program to find the sum of the series $ 1+3+5+......+n $.
Q.3 Solve both questions :
What is inheritance? Discuss different types of inheritance with examples.
What is operator overloading? Write a program in C++ to overload unary minus operator.
Q.4 Solve both questions :
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.
Discuss why converting a base-class pointer to a derived-class pointer is considered dangerous by compiler.
Q.5 Solve both questions :
Differentiate between abstract class and interface with suitable examples.
What is access modifier in C++? Differentiate between each type.
Q.6 Solve both questions :
Differentiate between a class and an object. Write an example (syntax) to define a class in C++.
With an example, explain the terms constructor and destructor.
Q.7 Solve both questions :
What is a friend function and what are its advantages? What are the guidelines that should be followed while using friend function?
Explain dangling pointer with the help of an example.
Q.8 Solve both questions :
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.
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:
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:
Write the name of the function in C++ used for opening a file for input only.
What is the purpose of using a derived class?
Is there any difference between public protection and private protection?
How does abstract class differ from interface?
What is the role of catch block in the exception handling?
Is it possible to return more than one value from a function? Explain with a small example.
What are the mutator functions? Give an example.
Discuss the role of default constructor when an object of a class is created.
Write a small code which illustrates the concept of multiple inheritance.
Differentiate between compile-time polymorphism and run-time polymorphism.
Q.2 Solve both questions :
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.
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'.
Q.3 Solve both questions :
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.
Write a program in C++ to read text file and display count of character in file.
Q.4 Solve both questions :
What is the main advantage of passing arguments by reference? When do we need to use default arguments in a function?
What do you mean by dynamic binding? How is it useful in OOP?
Q.5 Solve both questions :
What is constructor? Write a program in C++ to find the area of the circle using constructor.
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.
Q.6 Solve both questions :
What do you mean by dynamic initialization of objects? Why do we need to do this? How is dynamic initialization of objects achieved?
Write a C++ program to define a class string and use overloaded == operator to compare two strings.
Q.7 Solve both questions :
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.
Write a C++ program to demonstrate example of hierarchical inheritance to get square and cube of a number.
Q.8 Solve both questions :
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?
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.
Q.9 Solve both questions :
Describe the relationship between class templates and inheritance. Why is it appropriate to call a class template a parameterized type?
Write a program that demonstrates how certain exception types are not allowed to be thrown.
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:
How void pointers differ from general pointers?
Is it possible to access data without any member function in the class? Justify your reason.
How precedence of operators effects evaluation of an expression?
Write the advantage of object-oriented programming over procedural programming.
Why we generally avoid goto in the programming?
What is the role of try block in the exception handling?
Write the difference between class and structure.
What is the use of scope resolution operator?
Why we require derive data types in the programming when we already have different data types?
Write a small code which illustrates the concept of multilevel inheritance.
Q.2 Solve both questions :
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.
What are command line arguments? Write a program in C++ to finding factorial for a given number using command line argument.
Q.3 Solve both questions :
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.
Write a C++ program to which replace all the words "dog" with "cat".
Q.4 Solve both questions :
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.
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 $
Q.5 Solve both questions :
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.
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.
Q.6 Solve both questions :
What is operator overloading? Write a program in C++ to overload unary minus operator.
A friend function cannot be used to overload the assignment operator =. Explain why.
Q.7 Solve both questions :
Discuss why converting a base-class pointer to a derived-class pointer is considered dangerous by the compiler.
What is a virtual function? Why we need virtual functions?
Q.8 Solve both questions :
What are the different forms of inheritance? Give an example for each.
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.
Q.9 Solve both questions :
What is the relationship between function templates and overloading? Explain with the help of an example
What are the advantages of using exception handling mechanism in a program? Explain with an example.
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:
Write the name of the function in C++ used for opening a file for input only.
What is the purpose of using a derived class?
Is there any difference between public protection and private protection?
How does abstract class differ from interface?
What is the role of catch block in the exception handling?
Is it possible to return more than one value from a function? Explain with a small example.
What are the mutator functions? Give an example.
Discuss the role of default constructor when an object of a class is created.
Write a small code which illustrates the concept of multiple inheritance.
Differentiate between compile-time polymorphism and run-time polymorphism.
Q.2 Solve both questions :
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.
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'.
Q.3 Solve both questions :
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.
Write a program in C++ to read text file and display count of character in file.
Q.4 Solve both questions :
What is the main advantage of passing arguments by reference? When do we need to use default arguments in a function?
What do you mean by dynamic binding? How is it useful in OOP?
Q.5 Solve both questions :
What is constructor? Write a program in C++ to find the area of the circle using constructor.
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.
Q.6 Solve both questions :
What do you mean by dynamic initialization of objects? Why do we need to do this? How is dynamic initialization of objects achieved?
Write a C++ program to define a class string and use overloaded == operator to compare two strings.
Q.7 Solve both questions :
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.
Write a C++ program to demonstrate example of hierarchical inheritance to get square and cube of a number.
Q.8 Solve both questions :
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?
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.
Q.9 Solve both questions :
Describe the relationship between class templates and inheritance. Why is it appropriate to call a class template a parameterized type?
Write a program that demonstrates how certain exception types are not allowed to be thrown.