0% found this document useful (0 votes)
30 views3 pages

Final Quiz Ii Oopc

Uploaded by

tanuja.it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Final Quiz Ii Oopc

Uploaded by

tanuja.it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

QUIZ II

Name
Roll No
Course Title OBJECT ORIENTED PROGRAMMING CONCEPTS
Course Code ITDC0201
Maximum Marks 5
Obtained Marks

Each question carries 0.25 marks Duration: 15


minutes

Fill in the Blanks:


1. The constructor that accepts an object of the same class as an argument is called a ________
constructor.
2. When an object goes out of scope, the _______________ is called automatically to release
resources.
3. A pointer that points to a deallocated memory location is called a ____________________
pointer.
4. Syntax for defining operator function is ______________________________________________.

Multiple Choice Questions:


5. Which of the following statements is correct for overloading the - operator as a unary operator?
a) The operator function should take two parameters.
b) The operator function should take no parameters.
c) The operator function should take one parameter.
d) The operator function should return void.

6. Which type of pointer does not point to any memory location until assigned a value?
a) Void pointer b) Null pointer
c) Dangling pointer d) None of the above

7. In C++, what typically happens when you dereference an uninitialized pointer?


a) The pointer value is automatically set to nullptr.
b) A compile-time error is generated.
c) It can lead to a runtime error by accessing an arbitrary memory address.
d) The program terminates without any error message.

8. What does the expression p - q yield if p and q are both pointers to elements of the same array?
a) The memory difference in bytes
b) The number of elements between p and q
c) A syntax error
d) The product of p and q

9. If char *p; and p holds the address 0x1000, what will p + 2 point to?
a) Address 0x1000 b) Address 0x1002
c) Address 0x1004 d) Address 0x1008

10. Which of the following operators cannot be overloaded in C++?


a) + (Addition) b) & (Address operator)
c) . (Dot) d) ++ (Increment)

11. Given the following class, which line will call the destructor of the object obj?
class Test {
public:
~Test() { /* Destructor code */ }
};
void function() {
Test obj;
} // Line A

a) The destructor is called when obj is created.


b) The destructor is called right before Line A.
c) The destructor is called after Line A when obj goes out of scope.
d) The destructor is never called for obj.

12. If a class Demo has a user-defined parameterized constructor, which statement below is true about
creating an object with Demo d;?
a) This will create an object using the "do-nothing" constructor.
b) This will result in a compilation error if no default constructor is defined.
c) The parameterized constructor will be called with default arguments.
d) The object will be created without calling any constructor.

13. If a class contains only a parameterized constructor and no default constructor, what will happen
when you attempt to create an object without passing any arguments?
a) The compiler will generate a "do-nothing" constructor automatically.
b) A compile-time error will occur.
c) The parameterized constructor will be called with default arguments.
d) The object will be created, but member variables will remain uninitialized.

14. What is a common purpose of overloading the operator = = in a class?


a) To provide a way to compare two objects of the class.
b) To allow the class to be used in arithmetic expressions.
c) To implement logical operations between two objects.
d) To perform a bitwise comparison of two objects.

15. In a definition of unary operator function using member function, we pass


a) Argument by value b) Argument by reference
c) Both (a) and (b) d) No argument

16. Which of the following statements is true for a copy constructor in C++?
a) It can only be called explicitly by the user.
b) It is invoked when an object is assigned to another existing object.
c) It is automatically called when an object is initialized with another object.
d) It cannot be defined by the user.

True or False:
Note: Write “True” or “False”, Short form T or F is not allowed.
17. A non-member function cannot be used to overload binary operators.
18. Void pointer can be typecast to any other pointer type.
19. Dereferencing a null pointer causes undefined behavior.
20. The address of operator & can be overloaded.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy