MCQs / Computer Science / NSCT: Web Development

NSCT: Web Development MCQs — Computer Science (page 4)

105 multiple-choice questions on NSCT: Web Development from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.

76. What does this JavaScript code print to the console? js console.log(1 + 2 + '3');

  1. 123
  2. 6
  3. 33
  4. 15

Answer: C) 33

Explanation: Running the code prints 33. Lesson 6.3 · Web Development

Discuss this question

77. If the root font size is 16px, 2rem equals:

  1. 8px
  2. 2px
  3. 32px
  4. 16px

Answer: C) 32px

Explanation: rem is relative to the root element. Lesson 6.2 · Web Development

Discuss this question

78. Removing whitespace and comments from JS/CSS files to reduce size is:

  1. Obfuscation for security
  2. Normalization
  3. Encryption
  4. Minification

Answer: D) Minification

Explanation: Smaller files download faster. Lesson 6.5 · Web Development

Discuss this question

79. Which CSS selector has the highest specificity?

  1. header
  2. header
  3. .header

Answer: C) header

Explanation: Id selectors beat class and element selectors. Lesson 6.2 · Web Development

Discuss this question

80. A two-dimensional page layout with rows and columns is best done with:

  1. <br tags
  2. CSS Grid
  3. position: absolute
  4. Flexbox only

Answer: B) CSS Grid

Explanation: Grid controls both axes. Lesson 6.2 · Web Development

Discuss this question

81. To run a function when a button is clicked, you use:

  1. addEventListener("click", fn)
  2. console.log
  3. setTimeout only
  4. onLoad only

Answer: A) addEventListener("click", fn)

Explanation: Event listeners respond to user actions. Lesson 6.3 · Web Development

Discuss this question

82. Which HTTP status code means "Not Found"?

  1. 200
  2. 404
  3. 301
  4. 500

Answer: B) 404

Explanation: The requested resource does not exist. Lesson 6.1 · Web Development

Discuss this question

83. What does this JavaScript code print to the console? js const o = {name: 'Ali', age: 22}; console.log(Object.keys(o).length);

  1. 0
  2. 2
  3. 22
  4. 1

Answer: B) 2

Explanation: Running the code prints 2. Lesson 6.3 · Web Development

Discuss this question

84. Angular is developed by Google and is written mainly in:

  1. Python
  2. Java
  3. TypeScript
  4. PHP

Answer: C) TypeScript

Explanation: TypeScript adds static types to JavaScript. Lesson 6.4 · Web Development

Discuss this question

85. The React hook used to store component state is:

  1. useEffect
  2. useMemo only
  3. useState
  4. useRef only

Answer: C) useState

Explanation: const [count, setCount] = useState(0). Lesson 6.4 · Web Development

Discuss this question

86. Changing /orders/105 to /orders/106 in the URL shows another customer's order. This vulnerability is:

  1. XSS
  2. Broken access control (IDOR)
  3. Clickjacking
  4. Phishing

Answer: B) Broken access control (IDOR)

Explanation: The server must check ownership on every request. Lesson 6.5 · Web Development

Discuss this question

87. A one-dimensional layout of items in a row or column is best done with:

  1. CSS Grid only
  2. Tables
  3. Floats only
  4. Flexbox

Answer: D) Flexbox

Explanation: Flexbox aligns items along one axis. Lesson 6.2 · Web Development

Discuss this question

88. A site sends the header Content-Security-Policy: script-src 'self'. This mainly helps prevent:

  1. DDoS
  2. Weak passwords
  3. SQL injection
  4. XSS by blocking scripts from other origins

Answer: D) XSS by blocking scripts from other origins

Explanation: Only same-origin scripts may run. Lesson 6.5 · Web Development

Discuss this question

89. What does this JavaScript code print to the console? js function counter() { let c = 0; return () = ++c; } const next = counter(); next(); next(); console.log(next());

  1. 3
  2. 2
  3. 1
  4. 0

Answer: A) 3

Explanation: Running the code prints 3. Lesson 6.3 · Web Development

Discuss this question

90. What does this JavaScript code print to the console? js console.log(typeof []);

  1. object
  2. undefined
  3. list
  4. array

Answer: A) object

Explanation: Running the code prints object. Lesson 6.3 · Web Development

Discuss this question

91. Variables declared with var are:

  1. Always global
  2. Not allowed in modern browsers
  3. Block-scoped constants
  4. Function-scoped and hoisted

Answer: D) Function-scoped and hoisted

Explanation: let/const are block-scoped. Lesson 6.3 · Web Development

Discuss this question

92. Validating form input only in browser JavaScript is insufficient because:

  1. Attackers can bypass the browser and send requests directly
  2. Browsers do not support validation
  3. The server cannot read forms
  4. JavaScript is slow

Answer: A) Attackers can bypass the browser and send requests directly

Explanation: Always validate on the server. Lesson 6.5 · Web Development

Discuss this question

93. React is best described as a:

  1. Web server
  2. Database
  3. CSS framework
  4. JavaScript library for building user interfaces

Answer: D) JavaScript library for building user interfaces

Explanation: Created by Meta (Facebook). Lesson 6.4 · Web Development

Discuss this question

94. A small piece of data that a server asks the browser to store and send back with later requests is a:

  1. Cookie
  2. Cache line
  3. Packet
  4. Header file

Answer: A) Cookie

Explanation: Cookies maintain sessions in stateless HTTP. Lesson 6.1 · Web Development

Discuss this question

95. Loading images only when they are about to appear on screen is:

  1. Lazy loading
  2. Caching headers only
  3. Minification
  4. Eager loading

Answer: A) Lazy loading

Explanation: It speeds up initial page load. Lesson 6.5 · Web Development

Discuss this question

96. In JavaScript, "5" == 5 is true but "5" === 5 is false because:

  1. == is a syntax error
  2. === converts types
  3. === compares both value and type
  4. Strings cannot be compared

Answer: C) === compares both value and type

Explanation: Use strict equality to avoid surprises. Lesson 6.3 · Web Development

Discuss this question

97. Status code 429 means:

  1. Server overloaded permanently
  2. Too many requests (rate limit exceeded)
  3. Not authorised
  4. Content moved

Answer: B) Too many requests (rate limit exceeded)

Explanation: The client must slow down. Lesson 6.1 · Web Development

Discuss this question

98. Which is a semantic HTML5 element?

  1. <article
  2. <span
  3. <div
  4. <b

Answer: A) <article

Explanation: Semantic tags describe meaning. Lesson 6.2 · Web Development

Discuss this question

99. JavaScript in the browser handles asynchronous tasks using:

  1. Busy waiting
  2. Multiple threads per function
  3. An event loop
  4. Interrupts

Answer: C) An event loop

Explanation: Callbacks run when the call stack is free. Lesson 6.3 · Web Development

Discuss this question

100. Which array method transforms every element and returns a new array of the same length?

  1. filter()
  2. map()
  3. find()
  4. push()

Answer: B) map()

Explanation: map applies a function to each element. Lesson 6.3 · Web Development

Discuss this question

Previous Page 4 of 5 Next

Practise NSCT: Web Development MCQs

More Computer Science chapters