MCQs / Computer Science / NSCT: Web Development

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

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.

51. What does this JavaScript code print to the console? js console.log(0.1 + 0.2 === 0.3);

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

Answer: B) false

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

Discuss this question

52. REST APIs usually exchange data in:

  1. BMP
  2. JSON
  3. MP3
  4. DOCX

Answer: B) JSON

Explanation: JSON is lightweight and easy to parse. Lesson 6.4 · Web Development

Discuss this question

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

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

Answer: B) 123

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

Discuss this question

54. The best way to prevent SQL injection in a web app is:

  1. Hiding the login page
  2. Using prepared statements/parameterised queries
  3. Using GET instead of POST
  4. Minifying JavaScript

Answer: B) Using prepared statements/parameterised queries

Explanation: User input is treated as data, not code. Lesson 6.5 · Web Development

Discuss this question

55. What does this JavaScript code print to the console? js console.log(Boolean(''), Boolean('0'));

  1. false true
  2. true true
  3. false false
  4. true false

Answer: A) false true

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

Discuss this question

56. What does this JavaScript code print to the console? js console.log('JavaScript'.slice(0, 4).toUpperCase());

  1. JAVA
  2. SCRIPT
  3. JAVASCRIPT
  4. Java

Answer: A) JAVA

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

Discuss this question

57. The meta viewport tag is mainly needed for:

  1. SEO keywords
  2. Security headers
  3. Database access
  4. Proper display on mobile devices

Answer: D) Proper display on mobile devices

Explanation: It sets the page width to the device width. Lesson 6.2 · Web Development

Discuss this question

58. Media queries in CSS are used for:

  1. Database queries
  2. Loading JavaScript
  3. Responsive design for different screen sizes
  4. Playing video

Answer: C) Responsive design for different screen sizes

Explanation: e.g. @media (max-width: 600px). Lesson 6.2 · Web Development

Discuss this question

59. Setting element.innerHTML = userInput is risky because:

  1. It can execute injected scripts (XSS)
  2. It only works in Chrome
  3. It is slow
  4. It deletes the DOM

Answer: A) It can execute injected scripts (XSS)

Explanation: Use textContent for untrusted text. Lesson 6.3 · Web Development

Discuss this question

60. Which is the best way to apply the same CSS to many pages?

  1. Inline styles on every element
  2. JavaScript alerts
  3. An external stylesheet linked with <link
  4. <font tags

Answer: C) An external stylesheet linked with <link

Explanation: External CSS is reusable and cached. Lesson 6.2 · Web Development

Discuss this question

61. Express is a popular framework for:

  1. Database design
  2. Spreadsheets
  3. Mobile games
  4. Node.js back-end applications

Answer: D) Node.js back-end applications

Explanation: It handles routing and middleware. Lesson 6.4 · Web Development

Discuss this question

62. A permanent redirect (old URL moved forever) uses status code:

  1. 304
  2. 302
  3. 301
  4. 307 only

Answer: C) 301

Explanation: Search engines update their index on 301. Lesson 6.1 · Web Development

Discuss this question

63. Which HTTP method is NOT idempotent?

  1. DELETE
  2. PUT
  3. GET
  4. POST

Answer: D) POST

Explanation: Repeating a POST may create duplicate resources. Lesson 6.1 · Web Development

Discuss this question

64. JSON.parse() is used to:

  1. Validate HTML
  2. Send HTTP requests
  3. Convert an object into a string
  4. Convert a JSON string into a JavaScript object

Answer: D) Convert a JSON string into a JavaScript object

Explanation: JSON.stringify does the reverse. Lesson 6.3 · Web Development

Discuss this question

65. In the CSS box model, the space between the border and the content is:

  1. Gap
  2. Outline
  3. Margin
  4. Padding

Answer: D) Padding

Explanation: Margin is outside the border. Lesson 6.2 · Web Development

Discuss this question

66. Which HTTP method should be used to retrieve data without changing it?

  1. PATCH
  2. DELETE
  3. GET
  4. POST

Answer: C) GET

Explanation: GET is safe and idempotent. Lesson 6.1 · Web Development

Discuss this question

67. The await keyword can be used:

  1. In any CSS file
  2. To declare variables
  3. Inside an async function to wait for a Promise
  4. Only in loops

Answer: C) Inside an async function to wait for a Promise

Explanation: It pauses the async function until the Promise settles. Lesson 6.3 · Web Development

Discuss this question

68. event.preventDefault() in a form submit handler:

  1. Stops the browser's default form submission
  2. Deletes the form
  3. Reloads the page
  4. Submits twice

Answer: A) Stops the browser's default form submission

Explanation: Useful for validating or sending with fetch. Lesson 6.3 · Web Development

Discuss this question

69. HTTPS protects data in transit using:

  1. Compression
  2. TLS encryption
  3. Base64 encoding
  4. Cookies

Answer: B) TLS encryption

Explanation: TLS encrypts the connection. Lesson 6.5 · Web Development

Discuss this question

70. An ORM (e.g. Prisma, Django ORM, Hibernate) lets developers:

  1. Encrypt networks
  2. Draw UI mock-ups
  3. Compress images
  4. Work with database tables as objects in code

Answer: D) Work with database tables as objects in code

Explanation: Object-Relational Mapping. Lesson 6.4 · Web Development

Discuss this question

71. An attacker posts a comment containing <script that runs in other users' browsers. This is:

  1. SQL injection
  2. Cross-site scripting (XSS)
  3. CSRF
  4. DDoS

Answer: B) Cross-site scripting (XSS)

Explanation: The script runs with the victim's privileges. Lesson 6.5 · Web Development

Discuss this question

72. A user who is logged in tries to open an admin page they have no permission for. The correct status code is:

  1. 403 Forbidden
  2. 404 Not Found
  3. 200 OK
  4. 401 Unauthorized

Answer: A) 403 Forbidden

Explanation: 401 is for missing authentication; 403 for missing permission. Lesson 6.1 · Web Development

Discuss this question

73. Two rules target the same paragraph: p { color: blue } and .note { color: red }. The paragraph has class="note". Its colour is:

  1. Blue
  2. Purple
  3. Black
  4. Red

Answer: D) Red

Explanation: The class selector is more specific. Lesson 6.2 · Web Development

Discuss this question

74. A DNS record that maps a domain to an IPv4 address is a/an:

  1. A record
  2. MX record
  3. TXT record
  4. CNAME record

Answer: A) A record

Explanation: MX is for mail; CNAME is an alias. Lesson 6.5 · Web Development

Discuss this question

75. When an event on a child element also triggers handlers on its parent elements, it is called:

  1. Closure
  2. Event hoisting
  3. Debouncing
  4. Event bubbling

Answer: D) Event bubbling

Explanation: Events propagate up the DOM tree. Lesson 6.3 · Web Development

Discuss this question

Previous Page 3 of 5 Next

Practise NSCT: Web Development MCQs

More Computer Science chapters