[amp_mcq option1=”const driverAge = 16;” option2=”const short driverAge = 16;” option3=”driverAge =16;” option4=”driverAge const =16; E. namedconst driverAge =16;” correct=”option1″]
The correct answer is: A. const driverAge = 16;
A named constant is a variable that cannot be changed after it has been initialized. To create a named constant, you use the const keyword followed by the variable name and its value. In this case, the variable name is driverAge and its value is 16.
The other options are incorrect for the following reasons:
- Option B: The
shortkeyword is used to declare a variable of typeshort. In this case, the variable type is not specified, so the variable is of typeint. - Option C: The assignment operator (
=) is used to assign a value to a variable. In this case, the variable is not declared, so the statement is not valid. - Option D: The keyword
constis used to declare a named constant. In this case, the variable name is not followed by an equal sign, so the statement is not valid. - Option E: The keyword
namedconstis not a valid keyword in C++.