JavaScript Programming
Final Assessment (Qns & Ans)
2025
General Instructions
1. Read All Questions Carefully: Make sure you understand each question.
2. Time Management: You have a specific amount of time to complete the exam.
Keep an eye on the clock and pace yourself.
3. Allowed Materials: Only use materials that are explicitly allowed. Unauthorized
materials can lead to disqualification.
4. ANS Format: Follow the required format for your ANS. For example, multiple-
choice questions might need you to select the best ANS, while essay questions
require detailed responses.
5. Academic Integrity: Adhere to the university's honor code. Any form of cheating or
plagiarism is strictly prohibited.
6. Technical Requirements: Ensure your computer and internet connection are
stable. For online exams, you might need a webcam and microphone for proctoring
purposes.
7. Submission: Submit your ANS before the time expires. Late submissions might
not be accepted.
©2024/2025
,1. What method would you use to create a promise in
JavaScript?
- A) `Promise.create()`
- B) `Promise.resolve()`
- C) `new Promise()`
- D) `Promise.then()`
- Correct ANS: C) `new Promise()`
- Rationale: A promise is created using the `new Promise()`
constructor, which takes a function as an argument.
2. Which of the following is true about closures in JavaScript?
- A) They can only access global variables.
- B) They can access outer function variables even after the
outer function has executed.
- C) They are only created in global function scopes.
- D) They cannot modify outer variables.
- Correct ANS: B) They can access outer function variables
even after the outer function has executed.
- Rationale: Closures maintain a reference to their lexical
scope, allowing them to access outer variables post-execution.
©2024/2025
,3. What will be the output of the following code?
```javascript
console.log(typeof null);
```
- A) "undefined"
- B) "null"
- C) "object"
- D) "string"
- Correct ANS: C) "object"
- Rationale: In JavaScript, `typeof null` returns "object,"
which is widely considered a quirk of the language.
4. Which JavaScript method is used to convert a JSON string
into a JavaScript object?
- A) `JSON.stringify()`
- B) `JSON.parse()`
- C) `JSON.convert()`
- D) `Object.fromJson()`
- Correct ANS: B) `JSON.parse()`
©2024/2025
, - Rationale: `JSON.parse()` is the method that converts a
JSON string into a corresponding JavaScript object.
5. What type of function is a 'generator' function in JavaScript?
- A) A synchronous function
- B) A callback function
- C) A function that can be paused and resumed
- D) An arrow function
- Correct ANS: C) A function that can be paused and
resumed
- Rationale: Generator functions can pause execution
(`yield`) and are resumed later, making them unique in managing
state.
Fill-in-the-Blank Questions
6. JavaScript uses ______________ for prototypal inheritance.
- Correct ANS: prototypes
- Rationale: JavaScript employs prototypes for inheritance,
allowing objects to inherit properties and methods from other
objects.
©2024/2025