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 onlyConceptIn a dynamically typed language, a variable is not restricted to one data type; each runtime value carries its own type. Web presentation also permits…

  1. A.

    P only

  2. B.

    Q only

  3. C.

    Both P and Q

  4. 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

  1. For P, a JavaScript variable can first hold 5 and later be reassigned to the string hello; the number value and the string value retain their respective types while the variable refers to them at different times.

  2. For Q, CSS background-image can paint an image without an <img> element, and the Canvas API can draw an image with drawImage(). 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 true to Q as well.

  • Neither P nor Q assigns false to 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.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs

Loading lesson…