Introduction To C Plus Plus - Study Mode

[#51] What function is used to return the length of a string in C++?
Correct Answer

(B) size()

[#52] Which of the following is not a valid C++ identifier?
Correct Answer

_variableName

Explanation

Solution: C++ Identifiers: Naming Rules In C++, identifiers are names you give to things like variables, functions, and classes. They must follow specific rules. Rules for Valid Identifiers: 1. They can contain letters (a-z, A-Z), digits (0-9), and underscores (_). 2. They must begin with a letter or an underscore. 3. They cannot contain spaces. 4. They cannot be C++ keywords (like int , float , while , etc.). Let's Check the Options: A) _variableName : This is valid. It starts with an underscore and uses letters. B) 2ndVariable : This is invalid . Identifiers cannot start with a digit. C) variable_name@ : This is invalid . It contains the "@" symbol, which is not allowed. D) VariableName : This is valid. It starts with a letter and uses letters. Therefore, the correct answer is E, Both (B) and (C) are not valid C++ identifiers.

[#53] What is the result of the expression: sizeof(int) in C++?
Correct Answer

(A) Size of int in bytes

[#54] Which C++ feature allows a function to call itself?
Correct Answer

(D) Recursion

[#55] What is static binding?
Correct Answer

(B) The process of linking the actual code with a procedural call during compile-time