1D0-735 practice question 4 of 15
Which of the following comparison statement will return true? A) X=10; Y=11; y--; x==y B) X=10; Y=11; Y++; x==y’ C) X=11; Y=10; y--; x==y; D) X=11; Y=10; y-= 1; x==y
Full set: 55 questionsThis question tests the understanding of JavaScript's decrement operator and equality comparison. In option A, the variable x is assigned the value 10, and y is assigned 11. The statement y-- is a post-decrement operation, which subtracts 1 from the current value of y. This changes y's value from 11 to 10. The final comparison x == y then evaluates 10 == 10, which correctly returns true. All other options result in a final comparison that evaluates to false.
In option B, y is incremented to 12. The comparison 10 == 12 is false. In option C, y is decremented to 9. The comparison 11 == 9 is false. In option D, y is reduced to 9. The comparison 11 == 9 is false.
1. ECMAScript® 2023 Language Specification (ECMA-262, 14th edition):
Section 13.4.5 Update Expressions: Defines the behavior of the decrement (--) operator. It specifies that the operation subtracts the value 1 from its operand.
Section 13.11 Equality Operators: Describes the IsLooselyEqual abstract comparison algorithm used by the == operator, which for two operands of the Number type, performs a direct numerical comparison.
2. Mozilla Developer Network (MDN) Web Docs:
Decrement (--) Operator: "The decrement (--) operator decrements (subtracts one from) its operand... If used postfix (for example, x--), the decrement operator decrements and returns the value before decrementing." The side effect is that the variable's stored value is reduced by one.
Equality (==) Operator: "The equality (==) operator checks whether its two operands are equal, returning a Boolean result."
3. W3Schools JavaScript Tutorial (Referenced by many university curricula):
JavaScript Arithmetic Operators: The page on arithmetic operators explains that -- is the decrement operator, which subtracts one from a variable's value.
JavaScript Comparison Operators: The page on comparison operators confirms that == checks for equal value.
Keep practicing
Take the free 1D0-735 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 1D0-735 practice questions
- Question 3Which of the following is an advantage of using the Virtual DOM?
- Question 6Marshall's computer previously contracted malware because he unknowingly clicked on an in…
- Question 7Which of the following is not a best practice when using JavaScript libraries?
- Question 10Scarlet has the following code in her script: Var namesArr =[‘’Joseph’,’ Charlotte’’, ‘’N…
- Question 11Which of the following comparison statements will return true?
- Question 12Which of the following will correctly declare the courseNumber variable as a siring data …
