MCQs / Computer Science / NSCT: Web Development

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

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.

26. What does this JavaScript code print to the console? js console.log([..."abc"].reverse().join(''));

  1. c,b,a
  2. a,b,c
  3. abc
  4. cba

Answer: D) cba

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

Discuss this question

27. HTTP status code 500 indicates:

  1. A missing page
  2. An internal server error
  3. A redirect
  4. A successful request

Answer: B) An internal server error

Explanation: The fault is on the server side. Lesson 6.1 · Web Development

Discuss this question

28. Which array method creates a new array with only the elements that pass a test?

  1. reduce()
  2. forEach()
  3. map()
  4. filter()

Answer: D) filter()

Explanation: filter keeps matching elements. Lesson 6.3 · Web Development

Discuss this question

29. In React, data passed from a parent component to a child is called:

  1. State
  2. Hooks
  3. Props
  4. Events

Answer: C) Props

Explanation: State is managed inside a component. Lesson 6.4 · Web Development

Discuss this question

30. Marking a session cookie HttpOnly prevents:

  1. JavaScript from reading the cookie
  2. The cookie from expiring
  3. The cookie from being sent over HTTPS
  4. The server from reading it

Answer: A) JavaScript from reading the cookie

Explanation: It reduces the damage of XSS. Lesson 6.5 · Web Development

Discuss this question

31. What does this JavaScript code print to the console? js const s = JSON.stringify({a: 1, b: [2, 3]}); console.log(s);

  1. {a: 1, b: [2, 3]}
  2. [object Object]
  3. {'a':1,'b':[2,3]}
  4. {"a":1,"b":[2,3]}

Answer: D) {"a":1,"b":[2,3]}

Explanation: Running the code prints {"a":1,"b":[2,3]}. Lesson 6.3 · Web Development

Discuss this question

32. Which system translates a domain name like example.com into an IP address?

  1. DNS
  2. HTTP
  3. ARP
  4. DHCP

Answer: A) DNS

Explanation: The Domain Name System resolves names. Lesson 6.1 · Web Development

Discuss this question

33. Arrow functions are written as:

  1. lambda a, b: a + b
  2. function = (a, b)
  3. a + b - (a, b)
  4. (a, b) = a + b

Answer: D) (a, b) = a + b

Explanation: Concise syntax for functions. Lesson 6.3 · Web Development

Discuss this question

34. What does this JavaScript code print to the console? js const nums = [4, 9, 16]; console.log(nums.map(Math.sqrt).includes(3));

  1. true
  2. false
  3. 9
  4. undefined

Answer: A) true

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

Discuss this question

35. What does this JavaScript code print to the console? js console.log([1, 2, 3, 4].reduce((a, b) = a + b, 0));

  1. 10
  2. 1234
  3. 24
  4. 4

Answer: A) 10

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

Discuss this question

36. Passwords should be stored on the server as:

  1. Encrypted with the same key as cookies
  2. Salted hashes (e.g. bcrypt)
  3. Plain text
  4. Base64 strings

Answer: B) Salted hashes (e.g. bcrypt)

Explanation: Hashing is one-way; salt defeats rainbow tables. Lesson 6.5 · Web Development

Discuss this question

37. What does this JavaScript code print to the console? js let n = 0; for (let i = 0; i < 5; i++) { if (i === 3) continue; n += i; } console.log(n);

  1. 10
  2. 6
  3. 3
  4. 7

Answer: D) 7

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

Discuss this question

38. REST APIs are stateless, meaning:

  1. Data cannot be changed
  2. Each request contains all information needed to process it
  3. The server stores the full session of each client
  4. Only GET is allowed

Answer: B) Each request contains all information needed to process it

Explanation: This makes them easy to scale. Lesson 6.4 · Web Development

Discuss this question

39. The default port for HTTPS is:

  1. 21
  2. 443
  3. 80
  4. 25

Answer: B) 443

Explanation: HTTP uses 80; HTTPS uses 443. Lesson 6.1 · Web Development

Discuss this question

40. A single-page application (SPA):

  1. Loads one HTML page and updates content dynamically
  2. Reloads every page from the server
  3. Has no URLs
  4. Cannot use JavaScript

Answer: A) Loads one HTML page and updates content dynamically

Explanation: React and Vue are often used for SPAs. Lesson 6.4 · Web Development

Discuss this question

41. HTML is used to define a web page's:

  1. Server logic
  2. Database schema
  3. Styling only
  4. Structure and content

Answer: D) Structure and content

Explanation: CSS styles it; JavaScript adds behaviour. Lesson 6.2 · Web Development

Discuss this question

42. OAuth 2.0 is mainly used for:

  1. Delegated authorisation (e.g. "Sign in with Google")
  2. Styling pages
  3. Routing packets
  4. Compressing data

Answer: A) Delegated authorisation (e.g. "Sign in with Google")

Explanation: Apps get limited access tokens. Lesson 6.4 · Web Development

Discuss this question

43. The alt attribute of an <img tag is important because it:

  1. Compresses the image
  2. Sets the image size
  3. Provides text for screen readers and when the image fails to load
  4. Links the image

Answer: C) Provides text for screen readers and when the image fails to load

Explanation: It improves accessibility and SEO. Lesson 6.2 · Web Development

Discuss this question

44. Docker helps web deployment by:

  1. Packaging the app with its dependencies into a container
  2. Designing logos
  3. Replacing the database
  4. Writing HTML

Answer: A) Packaging the app with its dependencies into a container

Explanation: "Works on my machine" problems disappear. Lesson 6.5 · Web Development

Discuss this question

45. What does typeof null return in JavaScript?

  1. "object"
  2. "number"
  3. "undefined"
  4. "null"

Answer: A) "object"

Explanation: A long-standing language quirk. Lesson 6.3 · Web Development

Discuss this question

46. Versioning an API as /api/v1/ and /api/v2/ helps to:

  1. Change the API without breaking existing clients
  2. Speed up the network
  3. Remove authentication
  4. Encrypt requests

Answer: A) Change the API without breaking existing clients

Explanation: Old clients keep using v1. Lesson 6.4 · Web Development

Discuss this question

47. Which keyword declares a block-scoped variable that cannot be reassigned?

  1. var
  2. let
  3. static
  4. const

Answer: D) const

Explanation: const prevents reassignment. Lesson 6.3 · Web Development

Discuss this question

48. What does this JavaScript code print to the console? js console.log('10' - 2);

  1. 102
  2. 8
  3. 10-2
  4. NaN

Answer: B) 8

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

Discuss this question

49. Server-side rendering (SSR) improves:

  1. Initial load speed and SEO
  2. Image quality
  3. Only database speed
  4. Password security

Answer: A) Initial load speed and SEO

Explanation: The server sends ready HTML. Lesson 6.4 · Web Development

Discuss this question

50. GraphQL differs from REST mainly because:

  1. It needs no server
  2. It uses only XML
  3. It cannot read data
  4. The client requests exactly the fields it needs from a single endpoint

Answer: D) The client requests exactly the fields it needs from a single endpoint

Explanation: It avoids over-fetching and under-fetching. Lesson 6.4 · Web Development

Discuss this question

Previous Page 2 of 5 Next

Practise NSCT: Web Development MCQs

More Computer Science chapters