Which of the following statements is/are true? P: In a dynamically typed…
2019
Which of the following statements is/are true?
P: In a dynamically typed scripting language such as JavaScript, types are associated with values rather than variables.
Q: An HTML web page cannot display an image without using the <img> element.
Select the correct answer from the options given below:
Answer: A. P only — ConceptIn a dynamically typed language, a variable is not restricted to one data type; each runtime value carries its own type. Web presentation also permits…
- A.
P only
- B.
Q only
- C.
Both P and Q
- D.
Neither P nor Q
Attempted by 122 students.
Show answer & explanation
Correct answer: A
Concept
In a dynamically typed language, a variable is not restricted to one data type; each runtime value carries its own type. Web presentation also permits several rendering mechanisms, so a claim based on one HTML element must be checked against CSS and graphics APIs.
Application
For P, a JavaScript variable can first hold
5and later be reassigned to the stringhello; the number value and the string value retain their respective types while the variable refers to them at different times.For Q, CSS
background-imagecan paint an image without an<img>element, and the Canvas API can draw an image withdrawImage(). Thus the claimed impossibility does not hold.
Cross-check and contrast
P only represents
P = true, Q = false.Q only reverses those assessments:
P = false, Q = true.Both P and Q assigns
trueto Q as well.Neither P nor Q assigns
falseto P as well.
Therefore, P only is the correct selection.
A video solution is available for this question — log in and enroll to watch it.