C++ Language MCQ Questions with Answers :
1. Which of the following languages is a subset of C++ language?
A. C language
B. Java Language
C. C# language
D. B language
Answer: A
2. Which of the following correctly describes C++ language?
A. Statically typed language
B. Dynamically typed language
C. Both Statically and dynamically typed language
D. Type-less language
Answer: A
3. Which of the following keyword supports dynamic method resolution?
A. abstract
B. Virtual
C. Dynamic
D. Typeid
Answer: B
4. Which of the following language is not supported by C++?
A. Exception Handling
B. Reflection
C. Operator Overloading
D. Namespaces
Answer: B
5. Which of the following language feature is not an access specifier in C++?
A. public
B. private
C protected
D. internal
Answer: D
6. What does STL stand for?
A. Simple Template Library
B. Standard Template Library
C. Static Type Library
D. Single Type-based Library
Answer: B
7. Which of the following is the most common way of implementingC++?
A. C++ programs are directly compiled into native code by a compiler
B. C++ programs are first compiled to intermediate code by a compiler and then executed by a virtual machine
C. C++ programs are interpreted by an interpreter
D. A C++ editor directly compiles and executes the program
Answer: A
8. What is the implicit pointer that is passed as the first argument for nonstatic member functions?
A. ‘self’ pointer
B. std::auto_ptr pointer
C. ‘Myself’ pointer
D. ‘this’ pointer
Answer: D
9. If X is the name of the class, what is the correct way to declare copy constructor of X?
A. X(X arg)
B. X(X* arg)
C. X(const X* arg)
D. X(const X& arg)
Answer: D
10. Which of the following operator cannot be overloaded?
A. = (assignment operator)
B. == (equality operator)
C. –> (arrow operator)
D.:: (scope resolution operator)
Answer: D
11. Which of the following operators can be overloaded?
A. (dot or member access operator)
B. & (address-of operator)
C. size of the operator
D. ?: (conditional operator)
Answer: B
12. How do we declare an abstract class?
A. By providing at least one pure virtual method (function signature followed by ==0;) in a class
B. By declaring at least one method abstract using the keyword ‘abstract’ in a class
C. By declaring the class abstract with the keyword ‘abstract’
D. It is not possible to create abstract classes in C++
Answer: A
13. How do we declare an ‘interface’ class?
A. By making all the methods pure virtual in a class
B. By making all the methods abstract using the keyword ‘abstract’ in a class
C. By declaring the class as the interface with the keyword ‘interface’
D. It is not possible to create interface class in C++
Answer: A
14. How many copies of a class static member are shared between objects of the class?
A. A copy of the static member is shared by all objects of a class
B. A copy is created only when at least one object is created from that class
C. A copy of the static member is created for each instantiation of the class
D. No memory is allocated for static members of a class
Answer: A
15. Which of the following is true about const member functions?
A. const members can be invoked on both const as well as nonconst objects
B. const members can be invoked only on const objects and not on nonconst objects
C. nonconst members can be invoked on const objects as well as nonconst objects
D. none of the above
Answer: A
16. When is std::bad_alloc exception thrown?
A. When a new operator cannot allocate memory
B. When an alloc function fails
C. When type requested for new operation is considered bad, the exception is thrown
D. When delete operator cannot delete the allocated (corrupted) object
Answer: A
17. Which header file should we include for using std::auto_ptr?
a. <memory>
B. <alloc>
C. <autoptr>
D. <smartptr>
Answer: C
18. STL is based on which of the following programming paradigms?
A. Structured Programming
B. Object-Oriented Programming (OOP)
C. Functional Programming
D. Aspect Oriented Programming (AOP)
Answer: C
19. Which of the following correctly describes the meaning of ‘namespace’ feature in C++?
A. Namespaces refer to the memory space allocated for names used in a program
B. Namespaces refer to space between teh names in a program
C. Namespaces refer to space between the names in a program
D. namespaces provide facilities for organizing the names in a program to avoid name clashes
Answer: D
20. Which of the following is the most general exception handler that catches exception of any type?
A. catch(std::exception)
B. catch(std::any_exception)
C. catch(…)
D. catch()
Answer: C
21. STL is based on which of the following programming paradigm?
a. Structured Programming
b. Object-Oriented Programming (OOP)
c. Functional Programming
d. Aspect Oriented Programming (AOP)
Ans: c
22. Which of the following correctly describes the meaning namespace’ feature in C++?
a. Namespaces refer to the memory space allocated for names used in a program
b. Namespaces refer to space between the names in a program
c. Namespaces refer to packing structure of classes in a program.
d. Namespaces provide facilities for organizing the names in a program to avoid name clashes.
Ans: d
23. Which of the following is the most general exception handler that catches the exception of ‘any type’?
a. catch(std::exception)
b. catch(std::any_exception)
c. catch(…)
d. catch()
Ans: c
24. Which of the following relationship is known as inheritance relationship?
a. ‘has-a’ relationship
b. ‘is-a’ relationship
c. association relationship
d. none of the above
Ans: b
25. Which of the following operators can be implemented as a nonmember operator?
a. = (assignment operator)
b. () (function call operator)
c. [] (array access operator)
d. + (addition operator)
Ans: d
26. Which of the STL containers store the elements contiguously (in adjacent memory locations)?
a. std:: vector
b. std:: list
c. std:: map
d. std::set
Ans: a
27. Which of the following is not recommended in a header file?
a. Type definitions (typedefs)
b. Class definitions
c. Function definitions
d. Template definitions
Ans: c
28. If the class name is X, what is the type of its “this” pointer (in a nonstatic, non-const member function)?
a. const X* const
b. X* const
c. X*
d. X&
Ans: b
29. Which of the following is the most preferred way of throwing and handling exceptions?
a. Throw by value and catch by reference.
b. Throw by reference and catch by reference.
c. Throw by value and catch by value
d. Throw the pointer value and provide a catch for the pointer type.
Ans: a
30. If class A is a friend of class B and if class B is a friend of class C, which of the following is true?
a. Class C is a friend of class A
b. Class A is a friend of class C
c. Class A and Class C do not have any friend relationship
d. None of the above
Ans: c
C++ Objective Type Questions pdf free Download ::
31. The conditional compilation. It is taken care of by the compiler
b. It is setting the compiler option conditionally
c. It is compiling a program based on a condition
d. none of the above
Ans: c
32. Originally ‘C’ was developed as:
a. System programming language
b. General purpose language
c. Data processing languaged. None of the above
Ans: b
33. The minimum number of temporary variables needed to swap the contents of 2 variable is:
a. 1
b. 2
c. 3
d. 0
Ans: d
34. A direct access file is:
a. A file in which records are arranged in a way they are inserted in a file
b. A file in which records are arranged in a particular order
c. Files which are stored on a direct access storage medium
d. None of the above
Ans: c
35. Which of the following is not an advantage of secondary memory
a. It is cost-effective
b. It has large storage capacity
c. It has the highest speed
d. It is easily portable
Ans: c
36. An inverted file
a. Locates information about data in small files that are maintained apart from actual data record
b. A file which stores opposite records
c. A file which stores information about records of a system
d. None of the above
Ans: a
37. Which of the following is not a file operation:
a. Repositioning
b. Truncating
c. Appending
d. None of the above
Ans: d
38. Which of the following is not a component of file system
a. Access method
b. Auxiliary storage management
c. Free integrity mechanism
d. None of the above
Ans: d
39. Seek time is
a. time taken to retrieve a data
b. Time taken by reading/write head mechanism to position itself over appropriate cylinder
c. Time is taken by the appropriate sector to come under reading/write
d. None of the above
Ans: b
40. Latency time is:
a. Time taken by reading/write head mechanism to position itself over appropriate cylinder
b. Time is taken to transfer data from memory
c. Time is taken by the appropriate sector to come under reading/write head
d. None of the above
Ans: c
41. ‘Prime area’ in the context of the file system is defined as
a. It is a memory area created by operating system
b. It is an area into which data records are written
c. It is the main area of a web paged. None of the above
Ans: b
42. The two types of file structure existing in the VSAM file area. Key sequenced structure, entry sequenced structure
b. Key sequence structure, exit sequenced structure
c. Entry sequence structure, exit sequenced structured. None of the above
Ans: c
43. In a multi-list organization. Records that have the equivalent value for a given secondary index item are linked together to form a list.
b. Records are loaded in the ordered sequence defined by collating sequence by the content of the key
c. Records are directly accessed by record key field
d. None of the above
Ans: a
44. Which of the following is/are advantages of cellular partitioned structure:
a. Simultaneous read operations can be overlapped
b. Search time is reduced
c. Both a & b
d. None of the above
Ans: c
45. *ptr++ is equivalent to:
a. ptr++
b. *ptr
c. ++*ptr
d. None of the above
Ans: d
46. Statement scanf(“%d”,80);
a. Assign an integer to a variable I
b. Give an error message
c. Print the value of Id. Assign a float to the variable i
Ans: a
47. Value of ix+j, if I,j are integer type and ix long types would be
a. integer
b. float
c. long integer
d. double precision
Ans: c
48. In a C language ‘3’ represents
a. A digit
b. An integer
c. A character
d. A word
Ans: c
49. In C language, a hexadecimal number is represented by writing
a. x
b. xo
c. ox
d. h
Ans: d
50. Expression C=i++ causes
a. Value of I assigned to C and then I incremented by 1
b. I to be incremented by 1 and the value of I assigned to Cc. Value of I assigned to C
d. I to be incremented by 1
Ans: a