Tokens in C ++ Programming MCQ Questions and Answers
Q1. In C++, the smallest individual unit in a program is known as a:
A) Identifier
B) Keyword
C) Token
D) Character
Answer: Token
Q2. Which of the following is not a category of tokens in C++?
A) Keywords
B) Identifiers
C) Literals
D) Headers
Answer: Headers
Q3. Which of the following is a valid identifier in C++?
A) 2value
B) value_2
C) int
D) @result
Answer: value_2
Q4. Which one of the following is not a valid keyword in C++?
A) for
B) repeat
C) while
D) switch
Answer: repeat
Q5. The keyword const in C++ is used to declare:
A) A dynamic variable
B) A constant variable
C) A macro
D) A function
Answer: A constant variable
Q6. Which of the following identifiers is invalid in C++?
A) _sum
B) result2
C) 9total
D) total_9
Answer: 9total
Q7. Which of the following is not a valid token in C++?
A) Identifier
B) Operator
C) Statement
D) Constant
Answer: Statement
Q8. Tokens in C++ are separated by:
A) Semicolons
B) White spaces
C) Parentheses
D) Keywords
Answer: White spaces
Q9. Which of the following is a punctuator in C++?
A) if
B) ;
C) &&
D) 42
Answer: ;
Q10. Which of the following is an invalid identifier?
A) student_name
B) StudentName
C) class
D) student1
Answer: class
Q11. In C++, the term “literals” refers to:
A) Fixed values
B) Variable names
C) Comments
D) Expressions
Answer: Fixed values
Q12. Which of the following is a string literal?
A) ‘A’
B) “Hello”
C) Hello
D) 10
Answer: “Hello”
Q13. The token ++ in C++ is known as a/an:
A) Arithmetic operator
B) Increment operator
C) Logical operator
D) Bitwise operator
Answer: Increment operator
Q14. The symbol { in C++ is a:
A) Operator
B) Punctuator
C) Identifier
D) Literal
Answer: Punctuator
Q15. Which of the following represents a floating-point literal?
A) 42
B) ‘A’
C) 3.14
D) “3.14”
Answer: 3.14
Q16. In C++, the identifier names are:
A) Case-insensitive
B) Case-sensitive
C) Ignored by compiler
D) Stored in lowercase only
Answer: Case-sensitive
Q17. Which keyword is used to define a function that does not return a value?
A) int
B) void
C) null
D) none
Answer: void
Q18. The character constant ‘A’ is stored internally as:
A) String
B) ASCII value
C) Unicode string
D) Integer array
Answer: ASCII value
Q19. The operator && in C++ represents:
A) Bitwise AND
B) Logical AND
C) Arithmetic AND
D) Boolean equality
Answer: Logical AND
Q20. Which of the following is not a valid C++ operator?
A) +
B) *=
C) <>
D) %=
Answer: <>
Q21. The keyword new in C++ is used for:
A) Deleting memory
B) Dynamic memory allocation
C) Creating macros
D) Declaring constants
Answer: Dynamic memory allocation
Q22. The token // in C++ is used to indicate:
A) Multi-line comment
B) Preprocessor directive
C) Single-line comment
D) String literal
Answer: Single-line comment
Q23. The token :: in C++ is called:
A) Conditional operator
B) Scope resolution operator
C) Stream operator
D) Bitwise operator
Answer: Scope resolution operator
Q24. The sizeof keyword in C++ is a:
A) Function
B) Compile-time operator
C) Macro
D) Run-time operator
Answer: Compile-time operator
Q25. Which of the following represents a character literal?
A) ‘Z’
B) “Z”
C) Z
D) ‘ZZ’
Answer: ‘Z’
Q26. Which of the following is a valid keyword in C++?
A) then
B) typename
C) repeat
D) begin
Answer: typename
Q27. The symbol -> in C++ is called:
A) Logical operator
B) Bitwise operator
C) Arrow operator
D) Scope operator
Answer: Arrow operator
Q28. A token that represents a fixed numeric value in C++ is known as:
A) Identifier
B) Keyword
C) Constant
D) Operator
Answer: Constant
Q29. Which of the following is a compound assignment operator in C++?
A) +
B) =
C) +=
D) ==
Answer: +=
Q30. Which of the following is not a valid punctuation symbol in C++?
A) (
B) )
C) ,
D) @
Answer: @
Q31. In C++, tokens are created during:
A) Compilation
B) Lexical analysis
C) Execution
D) Linking
Answer: Lexical analysis
Q32. The keyword this in C++ refers to:
A) Base class
B) Current object
C) Global function
D) Static member
Answer: Current object
Q33. The identifier in C++ must not:
A) Contain digits
B) Start with a digit
C) Contain underscores
D) Contain uppercase letters
Answer: Start with a digit
Q34. Which operator has the highest precedence in C++?
A) &&
B) ++
C) +
D) =
Answer: ++
Q35. Which of the following is not an arithmetic operator in C++?
A) +
B) *
C) /
D) &&
Answer: &&
Q36. The token #include is part of:
A) Preprocessor directive
B) Function declaration
C) Class definition
D) Namespace
Answer: Preprocessor directive
Q37. A group of characters enclosed within double quotes is known as:
A) Character literal
B) Identifier
C) String literal
D) Keyword
Answer: String literal
Q38. Which of the following keywords is used to create an alias for a data type?
A) typedef
B) using
C) alias
D) rename
Answer: using
Q39. Which of the following is not a keyword in C++?
A) static
B) include
C) private
D) protected
Answer: include
Q40. The token : in the declaration class B : public A represents:
A) Inheritance operator
B) Conditional operator
C) Punctuator
D) Cast operator
Answer: Inheritance operator
Q41. Which operator is used for member access through an object?
A) .
B) ->
C) ::
D) *
Answer: .
Q42. The literal ‘0’ and the integer 0 in C++ are:
A) Identical
B) Different tokens
C) Same ASCII value
D) Same memory type
Answer: Different tokens
Q43. In C++, keywords are:
A) User-defined
B) Case-sensitive
C) Reserved words
D) Ignored by compiler
Answer: Reserved words
Q44. The token ? : in C++ is known as:
A) Conditional operator
B) Ternary operator
C) Logical operator
D) Bitwise operator
Answer: Conditional operator
Q45. Which of the following literals represents a hexadecimal number?
A) 012
B) 0x12
C) 12.0
D) 0b12
Answer: 0x12
Q46. In C++, a single-line comment begins with:
A) /*
B) //
C) #
D) \\
Answer: //
Q47. Which keyword is used to terminate a loop early?
A) break
B) stop
C) return
D) exit
Answer: break
Q48. The keyword namespace in C++ is used for:
A) Function overloading
B) Avoiding name conflicts
C) Declaring macros
D) Managing memory
Answer: Avoiding name conflicts
Q49. The token << is known as:
A) Insertion operator
B) Extraction operator
C) Bitwise AND
D) Left shift only
Answer: Insertion operator
Q50. In C++, an identifier can contain:
A) Only lowercase letters
B) Letters, digits, and underscores
C) Only alphabets
D) Only special symbols
Answer: Letters, digits, and underscores
Q51. Which operator is used to access a class member using a pointer to the object?
A) .
B) ->
C) ::
D) *
Answer: ->
Q52. The literal true in C++ is of type:
A) int
B) bool
C) char
D) float
Answer: bool
Q53. Which of the following symbols is a bitwise operator in C++?
A) &
B) &&
C) and
D) !
Answer: &
Q54. Which keyword in C++ defines a constant that cannot be changed?
A) #define
B) static
C) const
D) let
Answer: const
Q55. The operator ! in C++ represents:
A) Bitwise NOT
B) Logical NOT
C) Negation of number
D) Modulus operator
Answer: Logical NOT
Q56. In C++, the keyword enum is used to define:
A) User-defined constants
B) Variables
C) Arrays
D) Namespaces
Answer: User-defined constants
Q57. Which one of the following is not a relational operator?
A) ==
B) <
C) >=
D) =
Answer: =
Q58. Which operator is used to access global variables when a local variable has the same name?
A) ->
B) .
C) ::
D) @
Answer: ::
Q59. A character constant in C++ is enclosed within:
A) Single quotes
B) Double quotes
C) Parentheses
D) Braces
Answer: Single quotes
Q60. Which of the following literals represents a long integer constant?
A) 42
B) 42L
C) 42.0
D) L42
Answer: 42L
Q61. Which operator is called the dereference operator?
A) ->
B) *
C) &
D) ::
Answer: *
Q62. Which keyword is used to handle exceptions in C++?
A) try
B) catch
C) throw
D) error
Answer: try
Q63. Which of the following is a valid floating literal?
A) 2.5e3
B) 2,5
C) e2.5
D) 2.5.0
Answer: 2.5e3
Q64. The # symbol in C++ is part of:
A) Operator
B) Literal
C) Preprocessor token
D) Punctuator
Answer: Preprocessor token
Q65. Which operator is used to get the address of a variable?
A) *
B) &
C) ->
D) %
Answer: &
Q66. The operator sizeof returns:
A) Runtime memory size
B) Size in bytes of a data type or variable
C) Array index
D) Storage class
Answer: Size in bytes of a data type or variable
Q67. Which of the following symbols represents the ternary operator?
A) if-else
B) switch
C) ?:
D) case
Answer: ?:
Q68. The token cout in C++ is defined in:
A) iostream
B) stdio.h
C) conio.h
D) namespace.h
Answer: iostream
Q69. Which of the following operators is right-associative in C++?
A) +
B) *
C) =
D) /
Answer: =
Q70. Which of the following is a keyword in C++?
A) this
B) virtual
C) operator
D) define
Answer: virtual
Q71. In C++, which keyword is used to dynamically release memory?
A) free
B) deleteAll
C) delete
D) remove
Answer: delete
Q72. A group of tokens forming a meaningful statement in C++ is called a:
A) Lexeme
B) Function
C) Sentence (statement)
D) Expression
Answer: Sentence (statement)
Q73. The keyword static in C++ specifies:
A) Constant variable
B) Storage class
C) Dynamic object
D) Inline function
Answer: Storage class
Q74. Which operator is used to read input from the standard input stream in C++?
A) <<
B) >>
C) ->
D) <
Answer: >>
Q75. Which of the following is a user-defined token in C++?
A) if
B) while
C) sum
D) new
Answer: sum
Q76. In C++, a token that starts with # is part of the:
A) Function declaration
B) Class definition
C) Preprocessor directive
D) Data type
Answer: Preprocessor directive
Q77. Which of the following cannot be used as an identifier in C++?
A) myData
B) _value
C) float
D) my_data2
Answer: float
Q78. The operator % in C++ is used for:
A) Division
B) Modulus operation
C) Percentage calculation
D) Remainder removal
Answer: Modulus operation
Q79. The keyword mutable in C++ is used for:
A) Constant objects
B) Allowing modification of class members in const objects
C) Memory management
D) Static variables
Answer: Allowing modification of class members in const objects
Q80. Which of the following is not a valid C++ keyword?
A) friend
B) public
C) typedefine
D) private
Answer: typedefine
Q81. The token ‘\\n’ in C++ represents:
A) Backslash
B) New tab
C) Newline character
D) Carriage return
Answer: Newline character
Q82. Which of the following symbols represents the logical OR operator?
A) |
B) &
C) ||
D) &&
Answer: ||
Q83. The keyword explicit in C++ is used with:
A) Variables
B) Constructors
C) Functions
D) Namespaces
Answer: Constructors
Q84. Which of the following is not a valid punctuator in C++?
A) (
B) [
C) ]
D) $
Answer: $
Q85. The token :: helps in:
A) Memory allocation
B) Resolving scope conflicts
C) Type casting
D) Declaring namespaces
Answer: Resolving scope conflicts
Q86. Which of the following is a valid keyword in C++?
A) define
B) volatile
C) package
D) default
Answer: volatile
Q87. The literal “A” in C++ represents:
A) Character
B) String literal
C) ASCII code
D) Integer
Answer: String literal
Q88. Which operator is used to perform bitwise XOR operation?
A) ^
B) &
C) |
D) ~
Answer: ^
Q89. Which of the following is a valid hexadecimal constant?
A) 0x7A
B) 07A
C) #7A
D) 7AH
Answer: 0x7A
Q90. The keyword register in C++ is used to:
A) Store variable in heap
B) Request storing variable in CPU register
C) Make variable global
D) Prevent changes to a variable
Answer: Request storing variable in CPU register
Q91. Which operator is used to allocate memory dynamically in C++?
A) malloc
B) alloc
C) new
D) allocate
Answer: new
Q92. The token endl in C++ belongs to which header?
A) iostream
B) stdio.h
C) conio.h
D) stream.h
Answer: iostream
Q93. The keyword private in C++ defines:
A) Friend class
B) Access specifier
C) Static member
D) Inline function
Answer: Access specifier
Q94. Which of the following represents an octal literal?
A) 012
B) 0x12
C) 12.0
D) 120b
Answer: 012
Q95. In C++, the operator == is used for:
A) Assignment
B) Comparison
C) Initialization
D) Casting
Answer: Comparison
Q96. The keyword auto in modern C++ indicates:
A) Automatic type deduction
B) Automatic variable
C) Dynamic memory
D) Register variable
Answer: Automatic type deduction
Q97. Which keyword is used to declare an abstract function in C++?
A) pure
B) virtual
C) abstract
D) static
Answer: virtual
Q98. The operator ~ in C++ performs:
A) Bitwise NOT
B) Logical NOT
C) Unary minus
D) Increment
Answer: Bitwise NOT
Q99. Which of the following tokens represents a floating-point constant in exponential form?
A) 10
B) 0.5
C) 5.2e2
D) 52.0
Answer: 5.2e2
Q100. The token ; in C++ is used to:
A) Separate expressions
B) Terminate statements
C) Denote comments
D) Mark function calls
Answer: Terminate statements
