Olete.in
Articles
Mock Tests
🧪 C/C MCQ Quiz Hub
C Multiple Choice Questions Set-1
Choose a topic to test your knowledge and improve your C/C skills
1. If the class name is X, what is the type of its “this” pointer (in a nonstatic, non-const member function)?
X&
X*
const X* const
X* const
2. Which classes allow primitive types to be accessed as objects?
Storage
Virtual
Friend
Wrapper
3. When is std::bad_alloc exception thrown?
When new operator cannot allocate memory
When alloc function fails
When type requested for new operation is considered bad, thisexception is thrown
When delete operator cannot delete the allocated (corrupted) object
4. Which one of the following is not a fundamental data type in C++
float
string
int
wchar_t
5. Which of the following is a valid destructor of the class name “Country”
int ~Country()
void Country()
int ~Country(Country obj)
. void ~Country()
6. Which of the following correctly describes C++ language?
Statically typed language
Dynamically typed language
Both Statically and dynamically typed language
Type-less language
7. Which of the following keyword supports dynamic method resolution?
abstract
Virtual
Dynamic
Typeid
8. Which of the following is the most preferred way of throwing and handling exceptions?
Throw by value and catch by reference.
Throw by reference and catch by reference.
Throw by value and catch by value
Throw the pointer value and provide catch for the pointer type.
9. Which of the following is not true about preprocessor directives
They begin with a hash symbol
They are processed by a preprocessor
They form an integral part of the code
They have to end with a semi colon
10. What’s wrong? while( (i < 10) && (i > 24))
the logical operator &amp;&amp; cannot be used in a test condition
the while loop is an exit-condition loop
the test condition is always false
the test condition is always true
11. A continue statement causes execution to skip to
the return 0; statement
the first statement after the loop
the statement following the continue statement
the next iteration of the loop
12. What’s wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6)
the question mark should be an equal sign
the first semicolon should be a colon
there are too many variables in the statement
the conditional operator is only used with apstrings
13. What’s wrong? for (int k = 2, k <=12, k++)
the increment should always be ++k
the variable must always be the letter i when using a for loop
there should be a semicolon at the end of the statement
the commas should be semicolons
14. Which of the following is not recommended in a header file?
Type definitions (typedefs)
Class definitions
Function definitions
Template definitions
15. Which of the STL containers store the elements contiguously (in adjacent memory locations)?
std::vector
std::list
std::map
std::set
16. Which of the following is not a standard exception built in C++.
std::bad_creat
std::bad_alloc
std::bad_cast
std::bad_typeid
17. What does STL stand for?#
Simple Template Library
Standard Template Library
Static Type Library
Single Type-based Library
18. What is the difference between overloaded functions and overridden functions?
Overloading is a dynamic or run-time binding and Overriding is static or compile-time binding
Redefining a function in a friend class is called function overriding while Redefining a function in a derived class is called an overloaded function.
Overloading is a static or compile-time binding and Overriding is dynamic or run-time binding
Redefining a function in a friend class is called function overloading while Redefining a function in a derived class is called as overridden function.
19. Which one of the following is not a valid reserved keyword in C++
Explicit
Public
Implicit
Private
20. Each pass through a loop is called a/an
enumeration
iteration
culmination
pass through
21. Which of the following is true about const member functions?
const members can be invoked on both const as well as nonconst objects
const members can be invoked only on const objects and not on nonconst objects
nonconst members can be invoked on const objects as well as nonconst objects
none of the above
22. Which of the following relationship is known as inheritancerelationship?
has-a’ relationship
is-a’ relationship
association relationship
none of the above
23. If class A is friend of class B and if class B is friend of class C, which of the following is true?
Class C is friend of class A
Class A is friend of class C
Class A and Class C do not have any friend relationship
none of the above
24. direct access file is:
A file in which recoreds are arranged in a way they are inserted in a file
A file in which records are arranged in a particular order
Files which are stored on a direct access storage medium
none of the above
25. Which of the following is not a component of file system
Access method
Auxiliary storage management
Free integrity mechanism
None of the above
26. Seek time is
time taken to retrieve a dta
Time taken by read/write head mechanism to position itself over appropriate cylinder
Time taken by appropriate sector to come under read/write
None of the above
27. Prime area’ in context of file system is defined as
It is memory area created by operating system
It is an area into which data records are written
It is the main area of a web page
None of the above
28. In mulit-list organization
Records that have equivalent value for a given secondary index item are linked together to form a list.
Records are loaded in ordered sequence defined by collating sequence by content of the key
Records are directly accessed by record key field
None of the above
29. Which of the following is/are advantages of cellular partitioned structure
Simultaneous read operations can be overlapped
Search time is reduced
Both a &amp; b
None of the above
30. *ptr++ is equivalenet to
ptr++
*ptr
++*ptr
None of the above
31. The conditional compilation
It is taken care of by the compiler
It is setting the compiler option conditionally
It is compiling a program based on a condition
None of the above
32. Originally ‘C’ was developed as
System programming language
General purpose language
Data processing language
none of the above
33. An inverted file
Locates information about data in small files that are maintained apart from actual data record
A file which stores opposite records
A file which stores information about records of a system
none of the above
34. Which of the following is not a file operation:
Repositioning
Truncating
Appending
none of the above
35. Latency time is
Time taken by read/write head mechanism to position itself over appropriate cylinder
Time taken to transfer a dta from memory
Time taken by appropriate sector to come under read/write head
None of above
36. The two types of file structure existing in VSAM file are
Key sequenced structure, entry sequenced structure
Key sequence structure, exit sequenced structure
Entry sequence structure, exit sequenced structure
none of the above
37. How many copies of a class static member are shared between objects of the class?
A copy of the static member is shared by all objects of a class
A copy is created only when at least one object is created from that class
A copy of the static member is created for each instntiation of the class
No memory is allocated for static members of a class
38. Which looping process checks the test condition at the end of the loop?
for
while
do-while
no looping process checks the test condition at the end
39. The default access level assigned to members of a class is _________
Private
Public
Protected
Needs to be assigned
40. Which of the following correctly describes the meaning of‘namespace’ feature in C++?
Namespaces refer to the memory space allocated for names used in a program
Namespaces refer to space between the names in a program
Namespaces refer to packing structure of classes in a program.
Namespaces provide facilities for organizing the names in aprogram to avoid name clashes.
41. Which of the following correctly describes the meaning of ‘namespace’ feature in C++?
Namespaces refer to the memory space allocated for names used in a program
Namespaces refer to space between teh names in a program
Namespaces refer to space between the names in a program
namespaces provide facilities for organizing the names in a program to avoid name clashes
42. Which of the following language is not supported by C++?
Exception Handling
Reflection
Operator Overloading
Namespaces
43. class derived: public base1, public base2 { } is an example of
Polymorphic inheritance
Multilevel inheritance
Hierarchical inheritance
Multiple inheritance
44. Which of the following languages is a subset of C++ language?
C language
Java Language
C# language
language
45. How do we declare an ‘interface’ class?
By making all the methods pure virtual in a class
By making all the methods abstract using the keyword ‘abstract’ in a class
By declaring the class as interface with the keyword ‘interface’
It is not possible to create interface class in C++
46. How do we declare an abstract class?
By providing at least one pure virtual method (function signature followed by ==0;) in a class
By declaring at least one method abstract using the keyword ‘abstract’ in a class
By declaring the class abstract with the keyword ‘abstract’
It is not possible to create abstract classes in C++
47. Which of the following is not an advantage of secondary memory
It is cost-effective
It has large storage capacity
It has highest speed
It is easily portable
48. What happens when a pointer is deleted twice?
It can abort the program
It can cause a failure
It can cause an error
It can cause a trap
49. Which of the following language feature is not an access specifier in C++?
public
private
protected
internal
50. Expression C=i++ causes
Value of i assigned to C and then i incremented by 1
i to be incremented by 1 and then value of i assigned to C
Value of i assigned to C
i to be incremented by 1
Submit