Vous êtes sur la page 1sur 10

RAJALAKSHMI ENGINEERING COLLEGE

Thandalam, Chennai – 602 105


Department of Mechatronics Engineering
MT6604 - OBJECT ORIENTED PROGRAMMING IN C++
Class Test – I

Roll No. : Name :

Year : Branch: Section:

I. Fill in the blanks:

1. C++ is an object-oriented programming language.

2. C++ is a superset of C.

3. In C++ execution begins at main() function.

4. The C++ statements terminate with semicolons.

5. C++ introduces a new comment symbol // (double slash).

6. The identifier cout (pronounced as ‘C out’) is a predefined object that represents the
standard output stream in C++.

7. In C++, the standard output stream represents the screen.

8. The operator << is called the insertion or put to operator.

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.

13. In C++, the standard input stream represents the screen.

14. The operator >> is known as extraction or get from operator.

15. The multiple use of << or >> in one statement is called cascading.

16. A typical C++ program would contain four sections.

17. The smallest individual units in a program are known as tokens.


18. Keywords are explicitly reserved identifiers and cannot be used as names for the program
variables or other user-defined program elements.

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.

23. The do-while is an exit-controlled loop.

24. while is also a loop structure, but is an entry-controlled one.

25. The for is an entry-controlled loop and is used when an action is to be repeated for a
predetermined number of times.

2 B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College


II. Choose the best answer:

1. #include <iostream> is called


a) Preprocessor directive
b) Inclusion directive
c) File inclusion directive
d) None of the mentioned

Answer: a

2. The #include directive


a) Tells the preprocessor to grab the text of a file and place it directly into the current file
b) Statements are not typically placed at the top of a program
c) All of the mentioned
d) None of the mentioned

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.

3. If the file name is enclosed in double quotation marks


a) The preprocessor treats it as a user-defined file
b) The preprocessor treats it as a system-defined file
c) The preprocessor treats it as a user-defined file & system-defined file
d) None of the mentioned

Answer: a

4. If the file name is enclosed in angle brackets


a) The preprocessor treats it as a user-defined file
b) The preprocessor treats it as a system-defined file
c) The preprocessor treats it as a user-defined file & system-defined file
d) None of the mentioned

Answer: b

5. How many types of comments are there in C++?


a) 1
b) 2
c) 3
d) 4

Answer: b

Explanation: There are two types of comments. They are double slash and slash started.

B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College 3


6. What type of comments does C++ support?
a) single line
b) multiline
c) single line and multi-line
d) none of the mentioned

Answer: c

7. What is a comment in C++?


a) comments are parts of the source code disregarded by the compiler
b) comments are executed by the compiler to find the meaning of the comment
c) comments are executable
d) none of the mentioned

Answer: a

Explanation: Comments are used to add meaning to the program.

8. Comments in C++ starts with _______ symbol.


a) //
b) \\
c) **
d) None of the above

Answer: a

9. What is used to write multi line comment in C++?


a) /* …. */
b) /$ …. $/
c) //
d) none of the mentioned

Answer: a

Explanation: The /* is used to write the multi line comment.

10. Pick the odd one out:


a) array type
b) character type
c) boolean type
d) integer type

Answer: a

Explanation: Array type is not the basic type and it is constructed using the basic type.

11. Which data type is used to represent the absence of parameters?


a) int
b) short
c) void
d) float

4 B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College


Answer: c

Explanation: void will not return anything.

12. Which type is best suited to represent the logical values?


a) integer
b) Boolean
c) character
d) all of the mentioned

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.

15. Which of the following will not return a value?


a) null
b) void
c) empty
d) free

Answer: b

16. Where does the execution of the program starts?


a) user-defined function
b) main function
c) void function
d) none of the mentioned

Answer: b

Explanation: Normally the execution of the program in C++ starts from main only.

B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College 5


17. How are many minimum numbers of functions need to be presented in C++?
a) 0
b) 1
c) 2
d) 3

Answer: b

Explanation: The main function is the mandatory part, it is needed for the execution of the
program to start.

18. All keywords in C++ are in


a) LowerCase
b) UpperCase letters
c) CamelCase letters
d) None

Answer: a

19. Which of the following is not a valid C++ variable name?


a) int number;
b) float rate;
c) int variable_count;
d) int $main;

Answer: d

Explanation: Since only underscore and no other special character is allowed in a variable
name, it results in an error.

20. Which of the following is true for variable names in C++?


a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords (like goto, static)
c) Variable names cannot start with a digit
d) Variable can be of any length

Answer: c

Explanation: According to the syntax for C variable name, it cannot start with a digit.

21. Which is valid C++ expression?


a) int my_num = 100,000;
b) int my_num = 100000;
c) int my num = 1000;
d) int $my_num = 10000;

Answer: b

Explanation: Space, comma and $ cannot be used in a variable name.

6 B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College


22. Which of the following is not an arithmetic operation?
a) a *= 10;
b) a /= 10;
c) a != 10;
d) a %= 10;

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

24. Which among the following is NOT a logical or relational operator?


a) !=
b) ==
c) ||
d) =

Answer: d

25. Which of the following are unary operators?


a) sizeof
b) –
c) ++
d) all of the mentioned

Answer: d

26. Associativity of an operator are:


a) Right to Left
b) Left to Right
c) Random fashion
d) Both Right to Left and Left to Right

Answer: d

27. Which of the following method are accepted for assignment?


a) 5 = a = b = c = d;
b) a = b = c = d = 5;
c) a = b = 5 = c = d;
d) None of the mentioned

Answer: b

B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College 7


28. Which of the following operators has the lowest precedence?
a) !=
b) &&
c) ?:
d) ,

Answer: d

29. Which operator is used for input stream?


a) >
b) >>
c) <
d) <<

Answer: b

Explanation: The operator of extraction is >> and it is used on the standard input stream.

30. The if...else statement can be replaced by which operator?


a) Bitwise operator
b) Conditional operator
c) Multiplicative operator
d) None of the mentioned

Answer: b

Explanation: In the conditional operator, it will predicate the output using the given condition.

31. The switch statement is also called as?


a) choosing structure
b) selective structure
c) certain structure
d) none of the mentioned

Answer: b

Explanation: The switch statement is used to choose the certain code to execute, So it is also
called as selective structure.

32. What is this operator called ?:?


a) conditional
b) relational
c) casting operator
d) none

Answer: a

Explanation: In this operator, if the condition is true means, it will return the first operator,
otherwise second operator.

8 B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College


33. Which of the following is a ternary operator?
a) &&
b) >>=
c) ?:
d) ->

Answer: c

34. Which operator works only with integer variables?


a) increment
b) decrement
c) both increment & decrement
d) none of the mentioned

Answer: c

35. Example of iteration in C++.


a) for
b) while
c) do-while
d) all of the mentioned

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

38. The insertion operator is another name for _____.


a) input operator
b) output operator
c) extraction operator
d) None of the above

Answer: b

B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College 9


39. The extraction operator is another name for _____.
a) input operator
b) output operator
c) extraction operator
d) None of the above

Answer: a

40. When will the cin can start processing of input?


a) After pressing return key
b) By pressing blank space
c) After pressing return key & BY pressing blank space
d) None

Answer: a
ALL THE BEST

10 B.BHUVANESWARAN | AP (SG) | CSE | Rajalakshmi Engineering College