Computer Science - Object Oriented Programming Using C++ MCQs Part 3

1. The last statement in a function is often a(n) _____

A.
return
B.
goodbye
C.
finish
D.
endfunction

 Answer Option A

2. When the function int someFunction(char c) throw( ) is executed, _____

A.
it can throw anything
B.
it may throw an integer
C.
it may throw a character
D.
it may not throw anything

 Answer Option D

3. The two statements that can be used to change the flow of control are

A.
if and switch
B.
if and while
C.
switch and do-while
D.
break and continue
E.
None of the above

 Answer Option A

4. If p and q are assigned the values 2 and 3 respectively then the statement p = q++

A.
gives an error message
B.
assigns a value 4 to p
C.
assigns a value 3 to p
D.
assigns a value 5 to p
E.
None of the above

 Answer Option C

5. Which of the following is the insertion operator?

A.
>>
B.
<<
C.
//
D.
/*
E.
both (a) and (b)

 Answer Option B

6. If you want only one memory location to be reserved for a class variable, no matter how many objects are instantiated, you should declare the variable as

A. static
B. unary
C. dynamic
D. volatile

 Answer Option A

7. To use a template class member function, use the ________ with the instantiation

A. scope resolution operator
B. dot operator
C. class definition
D. keword template

 Answer Option B

8. When a class is derived from another derived class, the newly derived class

A. may have more liberal access to a base class member than its immediate predecessor
B. may have the same type of access to a base class member as its immediate predecessor
C. may have more limited access to a base class member than its immediate predecessor
D. both (b) and (c)

 Answer Option C

9. If you assign a default value to any variable in a function prototype's parameter list, then _____

A. all other parameters in the function prototype must have default values
B. all parameters to the right of that variable must have default values
C. all parameters to the left of that variable must have default values
D. no other parameters in that prototype can have default values

 Answer Option B

10. The dot operator (or class member access operator) connects the following two entities (reading from left to right):

A. a class member and a class object
B. a class object and a class
C. a class and a member of that class
D. a class object and a member of that class

 Answer Option D

11. Which of the following calls a function named displayName, passing it no actual arguments?

A. call displayName;
B. call displayName ();
C. displayName;
D. displayName();

 Answer Option D

12. The feature that allows you to use the same function name for separate functions that have different argument lists is called _____

A. overriding
B. overloading
C. constructing
D. destructing

 Answer Option B

13. Which of the following are valid characters constants?

A. '\n'
B. '\\'
C. '\0'
D. All of the above
E. None of the above

 Answer Option D

14. With a template class, _____ type is generic

A. no
B. exactly one
C. at least one
D. at most one

 Answer Option C

15. If you want to use a class to define objects in many different programs, you should define the class in a C++ _____ file

A. header
B. program
C. source
D. text

 Answer Option A

16. Functions that returns information about an object's state can be classified as ________

A. inspector functions
B. mutator functions
C. auxiliary functions
D. manager functions

 Answer Option A

17. An auxiliary function _____

A. return information about data members
B. changes the state of data members
C. performs an action or service
D. creates and destroys objects

 Answer Option C

18. To create and execute a C++ program, you need to have access to

A. a C++ compiler
B. a C++ translator
C. an object code editor
D. a text editor
E. both (a) and (d)

 Answer Option E

19. If you omit any constructor argument when you instantiate an object, you must use default values______

A. for all parameters to the constructor
B. for all parameters to the right of the argument
C. for all parameters to the left of the argument
D. for no other parameters

 Answer Option B

20. Many programmers separate a class into two files: _____

A. one for the declarations and one for the implementations
B. one for the void functions and one for the other functions
C. one for the public data and one for the private data
D. one for the primary functions and one for the auxiliary functions

 Answer Option A

21. Files whose names end in .h are called _____ files

A. handy
B. header
C. helper
D. helping

 Answer Option B

22. When accessing a structure member, the identifier to the left of the dot operator is the name of

A. a structure member
B. a structure tag
C. a structure variable
D. the keyword struct

 Answer Option C

23. Assume that a program contains a programmer-defined void function. When C++ encounters the function's closing brace (}), C++ returns to the statement _____

A. immediately above the statement that called the function
B. that called the function
C. immediately below the statement that called the function

 Answer Option C

24. Inheritance occurs when a class adopts all the traits of _________

A. an object
B. a parent class
C. a variable
D. a function

 Answer Option B

25. Template classes that have already been written to perform common class tasks are called _____

A. container classes
B. receptacle classes
C. repository classes
D. alembic classes

 Answer Option A

26. A _____ is a single item of information about a person, place, or thing

A. data file
B. field
C. program file
D. record

 Answer Option B

27. Which (if any) of the following is NOT a programmer-defined type

A. an array
B. a structure
C. a class
D. All of the above are programmer-defined types

 Answer Option D

28. Assume a program contains a void function named displayName, which requires no formal parameters. Which of the following is a correct function prototype for this function?

A. displayName;
B. displayName(void);
C. void displayName;
D. void displayName();
E. void displayName(none);

 Answer Option D

29. A file pointer always contains the address of the file

A. True
B. False

 Answer Option B

30. You declare a function with a function _____, which is typically entered at the beginning of the program, below the #include directives

A. call
B. prototype declaration
C. definition
D. pointer

 Answer Option B

31. The function whose prototype is Item getData(void); returns _____

A. the address of a structure
B. a copy of a structure
C. a pointer to a structure
D. nothing

 Answer Option D

32. Using new may result in less _____ memory than using an array

A. wasted
B. used
C. RAM
D. ROM

 Answer Option A

33. The most common operation used in constructors is

A. addition
B. overloading
C. assignment
D. polymorphism

 Answer Option C

34. In a simple 'if' statement with no 'else'. What happens if the condition following the 'if is false?

A. the program searches for the last else in the program
B. nothing
C. control 'falls through' to the statement following 'if
D. the body of the statement is executed
E. None of the above

 Answer Option C

35. If two types of errors may be thrown, you should write _______

A. no catch blocks
B. one catch block with two arguments
C. two catch block-one with an argument, and one without
D. two catch blocks with one argument each

 Answer Option D

36. The name of a function ends with

A. double quotes
B. single quotes
C. parenthesis
D. #
E. None of the above

 Answer Option C

37. Which of the following is not a programming control structure?

A. repetition
B. selection
C. sequency
D. sorting

 Answer Option D

38. The bitwise OR operator is a

A. unary operator
B. binary operator
C. ternary operator
D. octal operator
E. None of the above

 Answer Option B

39. A class Stockltems has four data members and three function members. You define 50 objects as members of the class. Which is true?

A. Only one copy of each of the tnree functions exists
B. Only one copy of each of the four data members exists
C. Both (a) and (b) are true
D. Neither (a) nor (b) is true

 Answer Option A

40. The continue statement should be written only

A. in the body of a loop.
B. in the nested loops
C. outside the body of a loop
D. any where
E. None of the above

 Answer Option A

41. A major advantage of inheritance is

A. reducing the time it takes to create new objects
B. not having to think about how objects will be used
C. reducing the amount of memory required to execute a progrma
D. enabling people who have not studied programming to create useful applications

 Answer Option A

42. When a variable exists or is accessible, it is said to be _____

A. immediate
B. in the path
C. available
D. in scope

 Answer Option D

43. The feature that allows the same operations to be carried out differently depending on the object is _____

A. polymorphism
B. polygamy
C. inheritane
D. multitasking

 Answer Option A

44. Which of the following is a C++ class?

A. >>
B. read()
C. cin
D. iostream

 Answer Option D

45. Precedence determines which operator

A. is evaluated first
B. is most important
C. is fastest
D. operates on the largest number
E. None of the above

 Answer Option A

46. When using the standard files that come with the C++ compiler, you should surround the header file name with _____

A. square brackets
B. angle brackets
C. parentheses
D. quotes

 Answer Option B

47. The loop condition in a flowchart is represented by a(n) _____

A. diamond
B. oval
C. parallelogram
D. rectangle

 Answer Option A

48. Which of the following, if any, are invalid names for a variable?

A. bankAccountNumber
B. first_Name
C. doubleNumber
D. operator
E. All of the above are valid names for variables

 Answer Option D

49. Inheritance is the principle that

A. classes with the same name must be derived from one another
B. knowledge of a general category can be applied to more specific objects
C. C++ functions may be used only if they have logical predecessors
D. one function name may invoke different methods

 Answer Option B

Comments

Most Popular

Remove Unicode Zero Width Space PHP

PhpStorm, return value is expected to be 'A', 'object' returned

Laravel file upload returns forbidden 403, file permission is 700 not 755