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('')); c,b,a a,b,c abc cba Answer: D) cba
Explanation: Running the code prints cba. Lesson 6.3 · Web Development
Discuss this question
27. HTTP status code 500 indicates: A missing page An internal server error A redirect 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? reduce() forEach() map() 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: State Hooks Props 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: JavaScript from reading the cookie The cookie from expiring The cookie from being sent over HTTPS 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); {a: 1, b: [2, 3]} [object Object] {'a':1,'b':[2,3]} {"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? DNS HTTP ARP 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: lambda a, b: a + b function = (a, b) a + b - (a, b) (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)); true false 9 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)); 10 1234 24 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: Encrypted with the same key as cookies Salted hashes (e.g. bcrypt) Plain text 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); 10 6 3 7 Answer: D) 7
Explanation: Running the code prints 7. Lesson 6.3 · Web Development
Discuss this question
38. REST APIs are stateless, meaning: Data cannot be changed Each request contains all information needed to process it The server stores the full session of each client 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: 21 443 80 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): Loads one HTML page and updates content dynamically Reloads every page from the server Has no URLs 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: Server logic Database schema Styling only 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: Delegated authorisation (e.g. "Sign in with Google") Styling pages Routing packets 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: Compresses the image Sets the image size Provides text for screen readers and when the image fails to load 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: Packaging the app with its dependencies into a container Designing logos Replacing the database 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? "object" "number" "undefined" "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: Change the API without breaking existing clients Speed up the network Remove authentication 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? var let static 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); 102 8 10-2 NaN Answer: B) 8
Explanation: Running the code prints 8. Lesson 6.3 · Web Development
Discuss this question
49. Server-side rendering (SSR) improves: Initial load speed and SEO Image quality Only database speed 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: It needs no server It uses only XML It cannot read data 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