You are on page 1of 11

C++ Objective Questions

1. C++ was originally developed by

a) Nicolas Wirth

b) Donald Knuth

c) Bjarne Stroustrup

d) Ken Thompson

2. The standard c++ comment

a) /

b) //

c) /* and */

d) None of these

3. The preprocessor directive #include is required if

a) Console output is used

b) Console input is used

c) Both console input and output is used

d) None of these

4. The operator << is called

a) an insertion operator

b) put to operator

c) either a or b

d) None of these

5. The operator >> is called

a) an extraction operator

b) a get from operator


c) either a or b

d) get to operator

6. When a language has the capability to produce new data type, it is called

a) Extensible

b) Overloaded

c) Encapsulated

d) Reprehensible

7. The C++ symbol <<

a) perform the action of sending the value of expression listed as its right to the outputs
strewn as the left.

b) is used to indicate the action from right to left

c) is adopted to resemble an arrow

d) All the above

8. C++ name was suggested by

a) Rrick Mascitti

b) Bjarne Stroustrup

c) Donald Knuth

d) Ken Thompson

9. What is a reference?

a) an operator

b) a reference is an alias for an object

c) used to rename an object

d) None of these

10. A constructor is called whenever

a) a object is declared
b) an object is used

c) a class is declared

d) a class is used

11. State the object oriented languages

a) C++

b) Java

c) Eiffel

d) All of the above

12. Overload function in C++

a) a group function with the same name

b) all have the same number and type of arguments

c) functions with same name and same number and type of arguments

d) All of the above

13. Operator overloading is

a) making c++ operators works with objects

b) giving new meaning to existing c++ operators

c) making new c++ operator

d) both a& b above

14. A constructor is called whenever

a) a object is declared

b) an object is used

c) a class is declared

d) a class is used

15. A class having no name

a) is not allowed
b) can't have a constructor

c) can't have a destructor

d) can't be passed as an argument

16. The differences between constructors and destructor are

a) constructors can take arguments but destructor can't

b) constructors can be overloaded but destructors can't be overloaded

c) both a & b

d) None of these

17. A destructor takes

a) one argument

b) two arguments

c) three arguments

d) Zero arguments

18. Constructors are used to

a) initialize the objects

b) construct the data members

c) both a & b

d) None of these

19. In C++ a function contained with in a class is called

a) a member function

b) an operator

c) a class function

d) a method

20. The fields in a class of a c++ program are by default

a) protected
b) public

c) private

d) None of these

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

a) C language
b) Java Language
c) C# language
d) B language
22. 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
23. Which of the following keyword supports dynamic method resolution?

a) Abstract
b) Virtual
c) Dynamic
d) Typeid
24. Which of the following language is not supported by C++?

a) Exception Handling

b) Reflection

c) Operator Overloading

d) Namespaces

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

a) Public

b) Private
c) Protected

d) Internal

26. What does STL stand for?

a) Simple Template Library

b) Standard Template Library

c) Static Type Library

d) Single Type-based Library

27. Which of the following is the most common way of implementing C++?

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

28. 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

29. 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)

30. Which of the following operator cannot be overloaded?

a) = (assignment operator)
b) == (equality operator)

c) –> (rrow operator)

d) :: (cope resolution operator)

31. Which of the following operators can be overloaded?

a) . (dot or member access operator)

b) & (address-of operator)

c) sizeof operator

d) ?: (conditional operator)

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

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

34. 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

35. 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

36. 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, this exception is thrown

d) When delete operator cannot delete teh allocated (corrupted) object

37. Which header file should we include for using std::auto_ptr?

a) <memory>

b) <alloc>

c) <autoptr>

d) <smartptr>

38. 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)

39. 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
40. 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()

41. What is the correct value to return to the operating system upon the successful completion
of a program?
a) -1
b) 1
c) 0
d) Programs do not return a value.
42. What is the only function all C++ programs must contain?

a) start()

b) system()

c) main()

d) program()

43. What punctuation is used to signal the beginning and end of code blocks?

a) { }

b) -> and <-

c) BEGIN and END

d) ( and )

44. What punctuation ends most lines of C++ code?

a) .(dot)

b) ;(semi-colon)

c) :(colon)

d) ' (single quote)


45. Which of the following is a correct comment?

a) */ Comments */

b) ** Comment **

c) /* Comment */

d) { Comment }

46. Which of the following is not a correct variable type?

a) float

b) real

c) int

d) double

47. Which of the following is the correct operator to compare two variables?

a) :=

b) =

c) equal

d) ==

48. Which of the following is the boolean operator for logical-and?

a) &

b) &&

c) |

d) |&

49. Evaluate !(1 && !(0 || 1))

a) True

b) False

c) Unevaluatable

d) None of above
50. Which of the following is pure object oriented language

a) C++

b) ADA

c) JAVA

d) C