OOPs Class Test - Answers
OOPs Class Test - Answers
OOPs Class Test - Answers
2. C++ is a superset of C.
6. The identifier cout (pronounced as ‘C out’) is a predefined object that represents the
standard output stream in C++.
9. The header file iostream should be included at the beginning of all programs that use
input/output statements.
10. Namespace defines a scope for the identifiers that are used in a program.
11. In C++, main() returns an integer type value to the operating system.
12. The identifier cin (pronounced ‘C in’) is a predefined object in C++ that corresponds to the
standard input stream.
15. The multiple use of << or >> in one statement is called cascading.
19. Identifiers refer to the names of variables, functions, arrays, classes, etc., created by the
programmer.
20. Constants refer to fixed values that do not change during the execution of a program.
21. In C++, all program processing can be coded by using only three logic structures.
22. The approach of using one or more of these basic control constructs in programming is
known as structured programming.
25. The for is an entry-controlled loop and is used when an action is to be repeated for a
predetermined number of times.
Answer: a
Answer: a
Explanation: The #include directive tells the preprocessor to grab the text of a file and place it
directly into the current file and are statements are typically placed at the top of a program.
Answer: a
Answer: b
Answer: b
Explanation: There are two types of comments. They are double slash and slash started.
Answer: c
Answer: a
Answer: a
Answer: a
Answer: a
Explanation: Array type is not the basic type and it is constructed using the basic type.
13. Which of the following is not one of the sizes of the floating point types?
a) short float
b) float
c) long double
d) double
Answer: b
Explanation: Logical values can be either true or false, so the boolean type is suited for it.
14. The size of an object or a type can be determined using which operator?
a) malloc
b) sizeof
c) malloc
d) calloc
Answer: b
Explanation: The sizeof operator gives the size of the object or type.
Answer: b
Answer: b
Explanation: Normally the execution of the program in C++ starts from main only.
Answer: b
Explanation: The main function is the mandatory part, it is needed for the execution of the
program to start.
Answer: a
Answer: d
Explanation: Since only underscore and no other special character is allowed in a variable
name, it results in an error.
Answer: c
Explanation: According to the syntax for C variable name, it cannot start with a digit.
Answer: b
Answer: c
23. Which of the following data type will throw an error on modulus operation (%)?
a) char
b) short
c) int
d) float
Answer: d
Answer: d
Answer: d
Answer: d
Answer: b
Answer: d
Answer: b
Explanation: The operator of extraction is >> and it is used on the standard input stream.
Answer: b
Explanation: In the conditional operator, it will predicate the output using the given condition.
Answer: b
Explanation: The switch statement is used to choose the certain code to execute, So it is also
called as selective structure.
Answer: a
Explanation: In this operator, if the condition is true means, it will return the first operator,
otherwise second operator.
Answer: c
Answer: c
Answer: d
36. Which looping process is best used when the number of iterations is known?
a) for
b) while
c) do-while
d) all looping processes
Answer: a
37. Which loop is most suitable to first perform the operation and then test the condition?
a) for loop
b) while loop
c) do-while loop
d) none of the mentioned
Answer: c
Answer: b
Answer: a
Answer: a
ALL THE BEST