COMPUTER PROGRAMMING MCQs by General knowledge Solutions
COMPUTER PROGRAMMING MCQs by General knowledge Solutions

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&
2. Which classes allow primitive types to be accessed as
objects?
a. Storage
b. Virtual
c. Friend
d. Wrapper
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. When delete operator cannot delete teh allocated
(corrupted) object
4. Which one of the following is not a fundamental data type
in C++
a. float
b. string
c. int
d. wchar_t
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()
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
7. Which of the following keyword supports dynamic method
resolution?
a. abstract
b. Virtual
c. Dynamic
d. Typeid
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 teh pointer type.
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
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
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
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
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
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
15. Which of the STL containers
store the elements contiguously (in adjecent memory locations)?
a. std::vector
b. std::list
c. std::map
d. std::set
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
17. What does STL stand for?
a. Simple
Template Library
b. Standard Template Library
c. Static Type Library
d. Single
Type-based 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 a overloaded fucntion.
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 fucnion.
19.
Which one of the following is not a valid reserved keyword in C++
a. Explicit
b. Public
c. Implicit
d. Private
20. Each pass through a loop is called a/an
a.
enumeration
b. iteration
c. culmination
d. pass through
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
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
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
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
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
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
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
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
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
30. *ptr++ is
equivalenet to:
a. ptr++
b. *ptr
c. ++*ptr
d. None of the above
No comments