Correct Answer: B) Semicolon (;) for statement
Explanation: In C, C++, and Java, the semicolon ;
marks the end of a statement, making it syntactically complete.
A) Constants never change values
B) Variables always store strings
C) Constants allow re-assignment
D) Variables only hold numbers
Correct Answer: A) Constants never change values
Explanation: Variables can store data that changes during program execution, while constants hold fixed values that cannot be altered after initialization.
A) Colon (:) for ending lines
B) Semicolon (;) for statement
C) Comma (,) for line breaks
D) Period (.) for termination
Correct Answer: B) Semicolon (;) for statement
Explanation: In C, C++, and Java, the semicolon ;
marks the end of a statement, making it syntactically complete.
A) Directly assign value
B) Use the let keyword
C) Declare int variable
D) Add int before value
Correct Answer: A) Directly assign value
Explanation: Python is dynamically typed, so variables are created by directly assigning a value, and their type is inferred.
A) Error in expression
B) 12 with no priority
C) 20 with wrong syntax
D) 27 after operations
Correct Answer: D) 27 after operations
Explanation: The parentheses ensure 4 + 5
is evaluated first, and the result is multiplied by 3
, giving 27
.
A) ^ symbol for inversion
B) ! symbol for negation
C) & symbol for condition
D) # symbol for logic
Correct Answer: B) ! symbol for negation
Explanation: The !
operator inverts the truth value of a boolean expression, making True
become False
and vice versa.
A) Reserves memory space
B) Sets an initial value
C) Ensures variables are static
D) Declares variable data type
Correct Answer: B) Sets an initial value
Explanation: Initialization assigns an initial value to a variable, ensuring it doesn’t contain unpredictable (garbage) data.
A) 3 with integer truncation
B) 3.0 for simplified result
C) 3.33 for exact division
D) 10 for unexpected logic
Correct Answer: C) 3.33 for exact division
Explanation: Floating-point division retains the decimal part, so dividing 10
by 3
results in approximately 3.33
.
A) exit for ending function
B) break to terminate loop
C) continue for skipping step
D) return to exit program
Correct Answer: B) break to terminate loop
Explanation: The break
keyword immediately exits the loop, stopping further iterations, regardless of the loop condition.
A) Enclose with /* */
B) Start lines with ##
C) Use double quotes ""
D) Use triple slashes ///
Correct Answer: A) Enclose with /* */
Explanation: In JavaScript, multi-line comments are written between /*
and */
, allowing developers to comment multiple lines of code.
A) str for textual data
B) int for whole numbers
C) float for real numbers
D) list for collections
Correct Answer: C) float for real numbers
Explanation: The float
data type in Python is used to represent decimal or real numbers with a fractional part.
A) Null due to no condition
B) False for exact match
C) True for equal values
D) Error in syntax usage
Correct Answer: C) True for equal values
Explanation: The >=
operator checks if the left-hand operand is greater than or equal to the right-hand operand, which is True
in this case.
A) string.length property
B) string.size method
C) string.count function
D) string.total property
Correct Answer: A) string.length property
Explanation: In JavaScript, the length
property is used to determine the number of characters in a string.
A) Returns infinity as result
B) Raises an error message
C) Produces a zero output
D) Crashes the entire program
Correct Answer: B) Raises an error message
Explanation: Most programming languages raise a runtime error or exception when attempting to divide by zero, as it’s mathematically undefined.
A) return for function body
B) def for defining code
C) lambda for expressions
D) function for definition
Correct Answer: D) function for definition
Explanation: The function
keyword is used to declare functions in JavaScript, followed by the function name and parameters.
A) Handle unmatched conditions
B) Exit the program entirely
C) Restart the case evaluation
D) Throw errors on no match
Correct Answer: A) Handle unmatched conditions
Explanation: The default
case in a switch
statement executes when none of the specified case
conditions are met.
A) float(number) method
B) math.ceil() for rounding
C) int(number) for nearest
D) round(number) function
Correct Answer: D) round(number) function
Explanation: The round()
function rounds a floating-point number to the nearest integer, based on the decimal part.
A) Enforcing strict data rules
B) Automatically detecting type
C) Casting between data types
D) Specifying types explicitly
Correct Answer: B) Automatically detecting type
Explanation: Type inference allows a programming language to deduce the type of a variable from its value without explicit declaration.
A) Use in
keyword directly
B) Use has()
for existence
C) Use contains()
method
D) Use search()
function
Correct Answer: A) Use in
keyword directly
Explanation: In Python, the in
keyword checks if a substring exists within a string, returning True
or False
.
A) is for object identity
B) == for value equality
C) and for logical check
D) not for inverse logic
Correct Answer: A) is for object identity
Explanation: The is
operator checks if two variables refer to the same object in memory, not just equal values.
A) Execute code regardless of exception
B) Skip the error-handling block
C) Retry the code causing error
D) Raise an exception manually
Correct Answer: A) Execute code regardless of exception
Explanation: The finally
block ensures that code runs whether an exception is raised or not, often used for cleanup operations.
& stay ahead of your competitors!
* Subscribe to our email newsletter to get the latest posts delivered right to your email.