MCQs — Programming Fundamentals

Practice questions for Computer Science.

Question 121

What is displayed? var n = 4; if (n > 5) { alert("Big"); } else { alert("Small"); }

A. A message box showing Big
B. A message box showing 4
C. No message is shown
D. A message box showing Small
Question 122

Which statement is used to check more than two conditions one after another?

A. for loop
B. function
C. if-else if
D. array
Question 123

An if-else if statement gives Grade A for marks 80 or more, Grade B for marks 60 or more, and Grade C otherwise. How many possible outcomes are there?

A. One
B. Three
C. Two
D. Four
Question 124

What is a loop in programming?

A. A statement that repeats a block of code
B. A statement that stops the program
C. A variable that stores text
D. A tag that adds a link
Question 125

Which pair of statements are loops in JavaScript?

A. if and else
B. var and let
C. alert and prompt
D. for and while
Question 126

How many times will this loop run? for (var i = 1; i <= 3; i++) { alert(i); }

A. 2 times
B. 4 times
C. 3 times
D. It never stops
Question 127

In the loop for (var i = 1; i <= 5; i++), what does i++ do?

A. It increases i by 1 after each repetition
B. It decreases i by 1
C. It sets i to 5
D. It stops the loop
Question 128

What is a loop inside another loop called?

A. A repeated loop
B. A nested loop
C. A parallel loop
D. A closed loop
Question 129

Which situation is a suitable use of a nested loop?

A. Storing one name in a variable
B. Showing one message box
C. Declaring a single variable
D. Printing a table of rows and columns
Question 130

What is an array?

A. A loop that runs many times
B. A tag that creates a list
C. A variable that can store many values under one name
D. A symbol used to compare values
Question 131

In an array, what is the index of the first item?

A. 0
B. 1
C. -1
D. 10
Question 132

What is displayed by alert(colours[2]); when var colours = ["red","green","blue"];?

A. green
B. blue
C. red
D. undefined
Question 133

What is a function in JavaScript?

A. A variable that stores a number
B. A comment that explains the code
C. A tag that displays an image
D. A block of code that can be used again whenever needed
Question 134

After a function named show is defined, which statement runs it?

A. function show;
B. call show
C. show();
D. run(show)
Question 135

Which code correctly defines a function named show?

A. function show() { alert("Hi"); }
B. show function() { alert("Hi"); }
C. function = show() { alert("Hi"); }
D. def show() { alert("Hi"); }
Question 136

What is debugging?

A. Writing a new program from the start
B. Finding and fixing errors in a web page or program
C. Deleting the whole web page
D. Choosing colours for a web page
Question 137

What is an error in a program often called?

A. A tag
B. A comment
C. A link
D. A bug
Question 138

A JavaScript line is written as alert("Hi" without the closing bracket. What type of error is this?

A. A logical error, because the plan was wrong
B. A hardware error
C. A syntax error, because the rules of the language were broken
D. A network error
Question 139

A program runs without any error message but shows a wrong total. What kind of error is this?

A. A logical error
B. A syntax error
C. A hardware error
D. A network error
Question 140

A web page shows a broken image icon instead of the picture. What should the developer check first?

A. That the page has a comment
B. That the file name in the src attribute is correct and the file is in the right place
C. That the heading uses <h1>
D. That the table has a border

🎯 How to get the most out of these questions

  • Attempt each question before revealing the answer.
  • Read the explanation even when you answered correctly — it reinforces the concept.
  • Note down any question you got wrong and revisit it the next day.
  • Use the pagination below the list to work through every page — do not stop at page 1.

📌 MCQs — FAQs

Are the answers in this section verified?

Yes — every answer on this page has been verified. MCQs also include explanations where available.

Can I print these questions?

Yes — use your browser's print option (Ctrl+P / Cmd+P) to print or save the page as PDF.

How often are questions updated?

New questions are added regularly. If a paper pattern changes, existing questions are reviewed and updated.

Scroll to Top