0% found this document useful (0 votes)
128 views5 pages

End of Term One Js Exam - Marking Guide

This document contains instructions and questions for a JavaScript exam. The exam is 50 marks and lasts 2 hours. It is for the course "Develop a Web Application Using JavaScript" with course code SFPWJ301. The exam will be proctored by instructors Stanley Mwizerwa and Louis Mukama. The exam contains 10 multiple choice questions testing JavaScript fundamentals like data types, variables, operators, and arrays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views5 pages

End of Term One Js Exam - Marking Guide

This document contains instructions and questions for a JavaScript exam. The exam is 50 marks and lasts 2 hours. It is for the course "Develop a Web Application Using JavaScript" with course code SFPWJ301. The exam will be proctored by instructors Stanley Mwizerwa and Louis Mukama. The exam contains 10 multiple choice questions testing JavaScript fundamentals like data types, variables, operators, and arrays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

COURSE: DEVELOP A WEB APPLICATION USING JAVASCRIPT

COURSE CODE: SFPWJ301

EXAM: CATI TERM I

PERIOD: 2HOURS

MARKS: 50

Instructions:

- Do all numbers
- Provide answers from this question paper

INSTRUCTORS: Stanley Mwizerwa &Louis Mukama

1) Which of the following keywords is used to define a variable in Javascript? (Marks 5)


A) var
B) let
C) Both A and B
D) None of the above
2) Which of the following statements is true about JavaScript? (Marks 5)
A) JavaScript is a weakly typed machine language
B) JavaScript is a compiled language
C) JavaScript works on both frontend and backend
D) None of the above
3) Upon encountering a commented statement, what does the Javascript Interpreter do? (Marks 5)
A) Throws an error
B) Ignores the statement
C) Gives a warning
D) None of the above
4) What will be the output of the following code snippet? (Marks 5)
let firstName = “Foe”
let lastName = “Doe”
console.log(“My name is ”+firstName+””+lastName)

A) Compilation Error
B) Runtime error
C) My name is FoeDoe
D) My name is Foe Doe
5) What will be the output for the following code snippet? (Marks 5)
var number1 = 4
var number2 = 6
var number3 =++number1
console.log(number2+number3)
A) 11
B) 10
C) Error
D) None of the above
6) What will be the output of the following code snippet? (Marks 5)
var a = 1;
a = “variable x”;
console.log(a)
A) 1
B) variable x
C) a variable x
D) None of the above

7) Which of the following is the correct output for the following JavaScript code: (Marks 5)
var farmAnimals = [“Cows”,”Sheep”,”Rabbits”,”Goats”]
farmAnimals[0] = “Cammel”;
farmAnimals[1] = “Rabbits”;
console.log(farmAnimals[1])

A) Sheep
B) Rabbit
C) Error
D) None
8) Javascript is a weakly typed language, give the difference between weakly/loosely typed languages
from strongly typed ones (Marks 5)
Weakly Typed (or Loosely Typed) Languages:
1. Implicit Type Conversion:
Weakly typed languages allow for automatic and implicit type conversions. For example, you can perform
operations between different data types without explicitly converting them.
2. Dynamic Typing:
The data type of a variable is not strictly defined. A variable can hold values of different types during its
lifetime.
3. Less Strict Type Checking:
Weakly typed languages are more permissive when it comes to type mismatches. Type errors might not be
caught until runtime.
4. Flexible Variable Usage:
Variables can be used in a more flexible manner, as their types can change dynamically.
Strongly Typed Languages:
1. Explicit Type Conversion (Casting):
In strongly typed languages, explicit type conversion (casting) is required when performing operations
between different data types.
2. Static Typing:
The data type of a variable is strictly defined at compile-time, and it cannot change during runtime.
3. Strict Type Checking:
Strongly typed languages enforce strict type checking, catching type errors at compile-time rather than
runtime. This helps in identifying and preventing type-related bugs early in the development process.
4. Less Flexible Variable Usage:
Variables are more rigid in terms of type, and their types are typically fixed.

9) List with help of an example at least 4 types of data types used in JavaScript (Marks 6)
- Numbers
- var age = 25; // integer
- var height = 5.9; // floating-point number
- String
- var name = "John";
var message = 'Hello, World!';
- Boolean
- var isStudent = true;
var hasJob = false;
- Arrays
- var colors = ['red', 'green', 'blue'];
var numbers = [1, 2, 3, 4, 5];

10) Explain with help of an example at least two non native/complex data types found in JavaScript
(Marks 4)
- Arrays
var numbers = [1, 2, 3, 4, 5];
console.log(numbers[2]);
- Object
- var person = {
- firstName: 'John',
- lastName: 'Doe',
- age: 30,
- address: {
- city: 'Example City',
- zipCode: '12345'
- },
- fullName: function() {
- return this.firstName + ' ' + this.lastName;
- }
};
- Regex
- var pattern = /hello/;
- var text = "Hello, World!";
-
- if (pattern.test(text)) {
- console.log("Match found!");
- } else {
- console.log("Match not found!");
- }
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Good Luck!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy