3.4 JavaScript
9 Computer Science · Chapter 3: Programming Fundamentals · Federal Board (FBISE)
3.4 JavaScript from Federal Board 9 Computer Science (9th Class) Chapter 3, Programming Fundamentals: 9 short and long questions and 69 MCQs with answers.
JavaScript MCQs
15 of 69- Q1
JavaScript is embedded in HTML using which tag?
Show answer
Correct answer: B. <script>
JavaScript goes inside the <script> tag.
- Q2
Which function displays a string on a webpage?
Show answer
Correct answer: C. document.write()
document.write() prints text on the page.
- Q3
An action sensed by a program that triggers a task is called a(n):
Show answer
Correct answer: C. Event
Such a triggered action is an event.
- Q4
Which symbol is used for a single-line comment?
Show answer
Correct answer: B. //
JavaScript uses // for single-line comments.
- Q5
Which function pops up a window to take user input?
Show answer
Correct answer: C. prompt()
prompt() takes input from the user.
- Q6
Which function informs the user about the result of an action?
Show answer
Correct answer: B. alert
alert displays a message to the user.
- Q7
An entity that stores a value for later use is a:
Show answer
Correct answer: B. Variable
A variable stores a value for later use.
- Q8
Which keyword declares a variable?
Show answer
Correct answer: C. var
The var keyword declares a variable.
- Q9
Which is a basic data type in JavaScript?
Show answer
Correct answer: B. Boolean
Number, String and Boolean are basic data types.
- Q10
The first assignment of a value to a variable is called:
Show answer
Correct answer: B. Initialization
The first value assignment is initialization.
- Q11
Which character can begin a variable name?
Show answer
Correct answer: C. A
Names cannot start with a number; a letter is valid.
- Q12
Using a variable before declaring and giving it a value shows:
Show answer
Correct answer: C. undefined
It displays 'undefined'.
- Q13
A variable name cannot start with a:
Show answer
Correct answer: D. Number
A variable name can never start with a number
- Q14
Which operator gives the remainder of a division?
Show answer
Correct answer: C. %
The modulus (%) gives the remainder.
- Q15
For reward = 5555, reward % 10 equals:
Show answer
Correct answer: A. 5
5555 divided by 10 leaves remainder 5.
JavaScript short questions
What are JavaScript variables? Give an example.
ImportantWhat are JavaScript Operators? Also give their types.
ImportantWhat are JavaScript Conditional Statements?
ImportantWhat are loops in JavaScript?
ImportantHow do you define and call a function in JavaScript?
ImportantWhat is an array in JavaScript? Give an example.
ImportantWhat is the difference between local and global variables in a function?
JavaScript long questions
Explain loops and nested loops in JavaScript with examples. Also define a function.
ImportantExplain variables, operators and conditional statements in JavaScript with examples.