111
92.4k

80+ Object Oriented Programming In cpp Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Programming Languages , Master of Science in Software Engineering (MSc SE) .

1.

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&
Answer» D. x&
2.

Which classes allow primitive types to be accessed as objects?

A. storage
B. virtual
C. friend
D. wrapper
Answer» B. virtual
3.

When is std::bad_alloc exception thrown?

A. when new operator cannot allocate memory
B. when alloc function fails
C. when type requested for new operation is considered bad, thisexception is thrown
D. object
Answer» D. object
4.

Which one of the following is not a fundamental data type in C++

A. float
B. string
C. int
D. wchar_t
Answer» A. float
5.

Which of the following is a valid destructor of the class name “Country”

A. int ~country()
B. void country()
C. int ~country(country obj)
D. void ~country()
Answer» B. void country()
6.

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» D. type-less language
7.

Which of the following keyword supports dynamic method resolution?

A. abstract
B. virtual
C. dynamic
D. typeid
Answer» A. abstract
8.

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 catch for the pointer type.
Answer» B. throw by reference and catch by reference.
9.

Which of the following is not true about preprocessor directives

A. they begin with a hash symbol
B. they are processed by a preprocessor
C. they form an integral part of the code
D. they have to end with a semi colon
Answer» A. they begin with a hash symbol
10.

What’s wrong? while( (i < 10) && (i > 24))

A. the logical operator && cannot be used in a test condition
B. the while loop is an exit-condition loop
C. the test condition is always false
D. the test condition is always true
Answer» D. the test condition is always true
11.

A continue statement causes execution to skip to

A. the return 0; statement
B. the first statement after the loop
C. the statement following the continue statement
D. the next iteration of the loop
Answer» C. the statement following the continue statement
12.

What’s wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6);

A. the question mark should be an equal sign
B. the first semicolon should be a colon
C. there are too many variables in the statement
D. the conditional operator is only used with apstrings
Answer» D. the conditional operator is only used with apstrings
13.

What’s wrong? for (int k = 2, k <=12, k++)

A. the increment should always be ++k
B. the variable must always be the letter i when using a for loop
C. there should be a semicolon at the end of the statement
D. the commas should be semicolons
Answer» B. the variable must always be the letter i when using a for loop
14.

Which of the following is not recommended in a header file?

A. type definitions (typedefs)
B. class definitions
C. function definitions
D. template definitions
Answer» D. template definitions
15.

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
Answer» C. std::map
16.

Which of the following is not a standard exception built in C++.

A. std::bad_creat
B. std::bad_alloc
C. std::bad_cast
D. std::bad_typeid
Answer» A. std::bad_creat
17.

What does STL stand for?

A. simple template library
B. standard template library
C. static type library
D. single type-based library
Answer» B. standard template library
18.

What is the difference between overloaded functions and overridden functions?

A. overloading is a dynamic or run-time binding and overriding is static or compile-time binding
B. redefining a function in a friend class is called function overriding while redefining a function in a derived class is called an overloaded function.
C. overloading is a static or compile-time binding and overriding is dynamic or run-time binding
D. redefining a function in a friend class is called function overloading while redefining a function in a derived class is called as overridden function.
Answer» B. redefining a function in a friend class is called function overriding while redefining a function in a derived class is called an overloaded function.
19.

Which one of the following is not a valid reserved keyword in C++

A. explicit
B. public
C. implicit
D. private
Answer» C. implicit
20.

Each pass through a loop is called a/an

A. enumeration
B. iteration
C. culmination
D. pass through
Answer» C. culmination
21.

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» B. const members can be invoked only on const objects and not on nonconst objects
22.

Which of the following relationship is known as inheritancerelationship?

A. ‘has-a’ relationship
B. ‘is-a’ relationship
C. association relationship
D. none of the above
Answer» A. ‘has-a’ relationship
23.

If class A is friend of class B and if class B is friend of class C, which of the following is true?

A. class c is friend of class a
B. class a is friend of class c
C. class a and class c do not have any friend relationship
D. none of the above
Answer» B. class a is friend of class c
24.

A direct access file is:

A. a file in which recoreds 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
Answer» C. files which are stored on a direct access storage medium
25.

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
Answer» C. free integrity mechanism
26.

Seek time is

A. time taken to retrieve a dta
B. time taken by read/write head mechanism to position itself over appropriate cylinder
C. time taken by appropriate sector to come under read/write
D. none of the above
Answer» D. none of the above
27.

‘Prime area’ in context of file system is defined as

A. it is 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 page
D. none of the above
Answer» B. it is an area into which data records are written
28.

In mulit-list organization

A. records that have equivalent value for a given secondary index item are linked together to form a list.
B. records are loaded in ordered sequence defined by collating sequence by content of the key
C. records are directly accessed by record key field
D. none of the above
Answer» B. records are loaded in ordered sequence defined by collating sequence by content of the key
29.

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
Answer» A. simultaneous read operations can be overlapped
30.

*ptr++ is equivalenet to:

A. ptr++
B. *ptr
C. ++*ptr
D. none of the above
Answer» C. ++*ptr
31.

The conditional compilation

A. 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 above
Answer» D. none of above
32.

Originally ‘C’ was developed as:

A. system programming language
B. general purpose language
C. data processing language
D. none of above
Answer» C. data processing language
33.

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 above
Answer» B. a file which stores opposite records
34.

Which of the following is not a file operation:

A. repositioning
B. truncating
C. appending
D. none of above
Answer» A. repositioning
35.

Latency time is:

A. time taken by read/write head mechanism to position itself over appropriate cylinder
B. time taken to transfer a dta from memory
C. time taken by appropriate sector to come under read/write head
D. none of above
Answer» D. none of above
36.

The two types of file structure existing in VSAM file are

A. key sequenced structure, entry sequenced structure
B. key sequence structure, exit sequenced structure
C. entry sequence structure, exit sequenced structure
D. none of above
Answer» C. entry sequence structure, exit sequenced structure
37.

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 instntiation of the class
D. no memory is allocated for static members of a class
Answer» C. a copy of the static member is created for each instntiation of the class
38.

Which looping process checks the test condition at the end of the loop?

A. for
B. while
C. do-while
D. no looping process checks the test condition at the end
Answer» C. do-while
39.

The default access level assigned to members of a class is ___________

A. private
B. public
C. protected
D. needs to be assigned
Answer» C. protected
40.

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 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 aprogram to avoid name clashes.
Answer» A. namespaces refer to the memory space allocated for names used in a program
41.

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. 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++?

A. exception handling
B. reflection
C. operator overloading
D. namespaces
Answer» D. namespaces
43.

class derived: public base1, public base2 { } is an example of

A. polymorphic inheritance
B. multilevel inheritance
C. hierarchical inheritance
D. multiple inheritance
Answer» B. multilevel inheritance
44.

Which of the following languages is a subset of C++ language?

A. c language
B. java language
C. c# language
D. language
Answer» D. language
45.

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 interface with the keyword ‘interface’
D. it is not possible to create interface class in c++
Answer» A. by making all the methods pure virtual in a class
46.

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. by providing at least one pure virtual method (function signature followed by ==0;) in a class
47.

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 highest speed
D. it is easily portable
Answer» A. it is cost-effective
48.

What happens when a pointer is deleted twice?

A. it can abort the program
B. it can cause a failure
C. it can cause an error
D. it can cause a trap
Answer» C. it can cause an error
49.

Which of the following language feature is not an access specifier in C++?

A. public
B. private
C. c protected
D. internal
Answer» D. internal
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 then value of i assigned to c
C. value of i assigned to c
D. i to be incremented by 1
Answer» D. i to be incremented by 1

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.