Sample Question Bank: Programming with JavaScript
Simple Questions (5]
Select the correct answer (single option):
1
Which metacharacter searches for a form feed character?
A \f C \b
B \o D \t
Select the correct answer (single option):
2
How many times does the compilation of the preprocessor happen before the
first JavaScript code is encountered?
A Twice C Once
B Thrice D Not at all
Fill in the blank:
3 ____________________ is a set of codes that uses an arbitrary source file
as its input data.
A Preprocessor C Web Application
B JavaScript D Functions
Select the correct answer (single option):
4
While creating a Web Worker when do you get a 404 error?
The path to the worker is
A C The bandwidth is less
incorrect
The new worker thread is
B The JavaScript file already exists D
initiated
Fill in the blank:
5
_______________________ is a data type or structure used in a script
wherever required to perform a task repeatedly.
A Booleans C Strings
B Functions D Objects
© Aptech Ltd. Page 1 of 6
Sample Question Bank: Programming with JavaScript
Average Questions (4)
Fill in the blank:
1
When an object is passed through a combination of properties and methods to
determine its semantics, it is called _______________.
A Traceur C CoffeeScript
B Duck-typing D Compilers
Select the correct answers (multiple options):
2
What are the different types of messages that are displayed in the Web
Console of the Firefox’s Web Developer?
JavaScript and CSS Error
A Network Requests C
Messages
B Security Errors and Warnings D Logged messages
Match the columns:
Match the online tools available for minifying JavaScript code with their features.
Online Tool Features
A YUI Compressor 1 Online compression tool that minifies the files to up to
3 80% of their original size
B AjaxminUi 2 Command-line tool that delivers over 20% of HTTP
compression
C JSCompress 3 Removes redundant comments and whitespaces from
JavaScript files
D JSMin 4 Minifies all the JavaScript files in a folder and nested
folders
A A-2, B-4, C-1, D-3 C A-1, B-3, C-2, D-4
B A-3, B-2, C-1, D-4 D A-2, B-3, C-1, D-4
© Aptech Ltd. Page 2 of 6
Sample Question Bank: Programming with JavaScript
Select the correct answers (multiple options):
4 Which are the commonly used methods used to fetch the content of an
HTML element?
element.setAttribute(attrib
A document.getElementById C
ute, value)
B JSON.parse() D getElementsByTagName
Difficult Questions (4)
Match the columns:
Match the regular expression patterns with their uses.
Regular Expression Uses
Pattern
1
Searches a match at the beginning of a
A Brackets 1
word
Specifies the number of occurrences of a
B Metacharacters 2
particular pattern
Searches range of characters between the
C Quantifiers 3
brackets
A A-3, B-1, C-2 C A-1, B-3, C-2
B A-3, B-2, C-1 D A-2, B-3, C-1
© Aptech Ltd. Page 3 of 6
Sample Question Bank: Programming with JavaScript
Select the correct answer (single option):
2
Which of these is the correct code to create a class with attributes year of
language, creator of that language?
function language(year, name){
function Language(year, name){
this.year=year;
this.year=year;
this.creator=name;
this.creator=name;
}
}
var Visual_Basic = new
var Visual_Basic = new
A language(1991,"Alan Cooper"); C language(1991,"Alan Cooper");
var Eiffel = new
var Eiffel = new
language(1983,"Anders
language(1983,"Anders
Hejlsberg");
Hejlsberg");
console.log(Visual_Basic.creat
console.log(creator);
or);
function language(year, name){ function (year){
year=year; this.year=year;
creator=name; this.creator=name;
} }
var Visual_Basic = new var Visual_Basic = new
B language(1991,"Alan Cooper"); D language(1991,Alan Cooper);
var Eiffel = new var Eiffel = new
language(1983,"Anders language(1983,Anders
Hejlsberg"); Hejlsberg);
console.log(Visual_Basic.creat console.log(Visual_Basic.creat
or); or)
© Aptech Ltd. Page 4 of 6
Sample Question Bank: Programming with JavaScript
Select the correct answer (single option):
3
Which of the following code snippet demonstrates finding HTML elements by class
name through the document object?
<!DOCTYPE html>
<html>
<!DOCTYPE html>
<body>
<html>
<p>Hello Script!</p>
<body>
<p class="intro">The DOM is
<p id="intro">Hello Script!</p>
very useful.</p>
<p>This example demonstrates the
<p class="intro">This example
<b>getElementsById</b>
demonstrates the
method.</p>
<b>getElementsByClassName</b>
<p id="demo"></p>
method.</p>
<script>
<p id="demo"></p>
var myElement =
A document.getElementById("intro") C <script>
var x =
;
document.getElementsByClassName
document.getElementById("demo").
("intro");
innerHTML =
document.getElementById("demo")
"The text from the intro
.innerHTML =
paragraph is " +
'The first paragraph (index 0)
myElement.innerHTML;
with class="intro": ' +
</script>
x[0].innerHTML;
</body>
</script>
</html>
</body>
</html>
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<body>
<body>
<p>Hello Script!</p>
<p>Hello Script!</p>
<p class="intro">This example
<p>This example demonstrates the
demonstrates the
<b>getElementsByTagName</b>
<b>querySelectorAll</b>
method.</p>
method.</p>
<p id="demo"></p>
<p id="demo"></p>
<script>
<script>
var x =
B document.getElementsByTagName("p D var x =
document.querySelectorAll("p.in
");
tro");
document.getElementById("demo").
document.getElementById("demo")
innerHTML =
.innerHTML = 'The first
'The text in first paragraph
paragraph (index 0) with
(index 0) is: ' +
class="intro": ' +
x[0].innerHTML;
x[0].innerHTML;
</script>
</script>
</body>
</body>
</html>
</html>
© Aptech Ltd. Page 5 of 6
Sample Question Bank: Programming with JavaScript
Select the correct answer (single option):
4
Which of these is the valid code in TypeScript to multiply two numbers?
function multiply(first: Function multiply(first
number, second: number): ,second) {
number { return first * second;
A return first * second; C }
} var result = multiply(1,
var result = multiply(1, 1); 1);
function multiply(first function multiply(first
,second) { ,second) {
B return first * second; D return first * second;
} }
var result = multiply(1, 1); var multiply(1, 1);
© Aptech Ltd. Page 6 of 6