Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

TCS693 JavaScript

Total questions: 47

Worksheet time: 26mins

Name
Class
Date
1.

JavaScript is designed for following purpose -

a)

To Style HTML Pages

b)

To Perform Server Side Scripting Opertion

c)

To add interactivity to HTML Pages.

d)

To Execute Query Related to DB on Server

2.

The output of the below code is:


<p id="demo"></p>


<script>

var text = "";

var i;

for (i = 0; i < 5; i++) {

text += "The number is " + i + "<br>";

}

document.getElementById("demo").innerHTML = text;

</script>

a)

The number is 0

The number is 1

The number is 2

The number is 3

The number is 4

The number is 5

b)

The number is 0

The number is 1

The number is 2

The number is 3

The number is 4

c)

The number is 1

The number is 2

The number is 3

The number is 4

The number is 5

d)

Why is that person using "var"???

3.

What is the difference between == and ===?

a)

The === operator compares two values, without taking into account their types. == compares the values, but also makes their types into account.

b)

Do I really need to reply this?

c)

The == operator compares two values, without taking into account their types. === compares the values, but also makes their types into account.

d)

The == operator is used to assign a value to a variable. === is used to compare the values of two variables.

4.

What are HTML Tags?

a)

HTML tags are composed of three things: an opening tag, content and ending tag. Some tags are unclosed tags.

b)

HTML tags are composed of three things: an opening tag, content and ending tag. All tags need to be closed.

c)

HTML tags define metadata about an HTML document. Metadata is data (information) about data.

d)

I didn't know that I was supposed to be studying

5.

What is the output of 10+20+"30" in JavaScript?

a)

102030 because since there is a string, all the + will be treated as string concatenation operator (not binary +).

b)

102030 because before you perform arithmetic operations you would have to explicitly convert those values to an actual number.

c)

That will throw an unhandled exception, a try catch block is required to prevent it.

d)

3030 because 10+20 will be 30. If there is numeric value before and after +, it treats as binary + (arithmetic operator).

6.
Which of the following is the largest heading? 
a)
h2
b)
h3
c)
h4
d)
h6
7.
Which is the correct way of defining an HTML5 document?
a)
<!DOCTYPE html>
b)
<!DOCTYPE HTML5>
c)
<!DOCTYPE html "PUBLIC">
d)
<DOCTYPE html>
8.
HTML5 incorporates three kinds of code: HTML, CSS and Javascript. Which of these provides the structure to a webpage?
a)
Javascript
b)
HTML
c)
CSS
d)
None
9.
What is an HTML element?
a)
The starting tag
b)
The ending tag
c)
The content between the tags
d)
Everything from start to end tag
10.
Which is the correct HTML element for inserting a line break?
a)
<b>
b)
<lb>
c)
<br>
d)
<break>
11.

Which of these is a loop?

a)

if(x<10)

b)

while(x<10)

c)

var x=10;

d)

text(x,10;10)

12.

Greater than or equal to

a)

> or =

b)

> || =

c)

>=

d)

<=

13.

What is a style sheet?

a)

A style sheet is used to build a consistent, transportable, and well-designed style template.

b)

To create a multicolor text on a web page

c)

It is used to define a container for navigation links

d)

It is used to define content aside from the content

14.

What should a HTML web page end with?

a)

</html>

b)

<head>

c)

</end>

d)

</body>

15.

Which tag would you use for an ordered list?

a)

<ol>

b)

<ul>

c)

<li>

d)

None of the above

16.

Which tag would you use to insert a image?

a)

<marquee>

b)

< a href>

c)

<br>

d)

<img src>

17.

JavaScript is designed for following purpose -

a)

To Style HTML Pages

b)

To Perform Server Side Scripting Opertion

c)

To add interactivity to HTML Pages.

d)

To Execute Query Related to DB on Server

18.

JavaScript is an ________ language.

a)

compiled

b)

interpreted

19.

Why JavaScript is called as Lightweight Programming Language ?

a)

because JS can provide programming functionality inside but up to certain extend.

b)

because JS is client side scripting

c)

because JS is available free of cost.

d)

because we can add programming functionality inside JS

20.

JavaScript Code can be called by using _________.

a)

RMI

b)

Function / Method

c)

Triggering Event

d)

Preprocessor

21.

Is this correct syntax to include JS Code inside HTML Page ?

<script type="text/javascript">

...

</script>

a)

Yes

b)

No

22.

We cannot Place JS Code in the body tag . Say true/false.

a)

True

b)

False.

23.
HTML attributes always appear where?
a)
In the opening tag
b)
In the closing tag
c)
Between the tags
d)
After the closing tag
24.

<script type="text/javascript">

x=4+"4";

document.write(x);

</script>

Output------?

a)

44

b)

8

c)

4

d)

Error output

25.
Which keyword do we need to define a function?
a)
function
b)
method
c)
onclick
d)
functionName()
26.
Which 1 of the following symbols is used for JavaScript comments?
a)
\\
b)
^
c)
?
d)
//
27.
How do we generate a random number?
a)
Math.random()
b)
random.number()
c)
number.random()
d)
Random.math()
28.

Which of the following platform(s) can be used to run Javascript Code

a)

Google Chrome

b)

Firefox

c)

Microsoft Edge

d)

Safari

29.
How do I change the size of an image?
a)
width / height
b)
scale
c)
size
d)
shrink
30.

1.Which of the following is the correct tag to create a text box?

a)

<input> text </input>

b)

<text>

c)

<input = “text”>

d)

<input type = “text”>

31.

What symbol should you use to target an id in css?

a)

.

b)

+

c)

id

d)

#

32.

What symbol should you use to target a class name in css?

a)

#

b)

()

c)

.

d)

class

33.

How do you change the font color with CSS?

a)

font-color: green;

b)

color: green;

c)

change-font-color: green;

d)

fontcolor=green;

34.

Which of the following is NOT a part of CSS?

a)

Property

b)

Selector

c)

Protocol

d)

Value

35.

Which of the following is NOT a type of CSS?

a)

Inline CSS

b)

Internal CSS

c)

External CSS

d)

Regular CSS

36.

How many types of heading tags are there?

a)

5

b)

3

c)

6

d)

7

37.

JavaScript was invented by

a)

Brendan Eich

b)

Tim Berners-Lee

c)

Wium Lie

d)

Bill Gates

38.

Which of the following CSS is correct?

a)

body {

background-color: lightblue;

}

b)

body {  bgcolor: lightblue;}

c)

body {  background-color: lightblue}

d)

body {  background: lightblue;}

39.

JavaScript can be placed in

a)

Head

b)

Body

c)

Both head and body

d)

Inline

40.

What is the DOM?

a)

Is an open standard file format, and data interchange format, that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and array data types

b)

Is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScript

c)

Is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable

d)

The Document Object Model is a cross-platform and language-independent interface that treats an XML or HTML document as a tree structure wherein each node is an object representing a part of the document

41.

What are the pop-up boxes types available in JavaScript?

a)

Alert, Redirect and Prompt

b)

Alert, Confirm and Prompt

c)

Nice try, a pop-up can be done only using jquery or a similar library

d)

Alert, Confirm, Redirect and Prompt

42.

What is the use of the required attribute in HTML5?

Name: <input type="text" name="name" required>

a)

This adds a red border over the input box for the user to visually recognize that it is required.

b)

It forces a user to fill text on the text field or text area before submitting the form. It is used for form validation. But, the "required" attribute is not properly written in this example.

c)

It would be nice to have that functionality, but due to browser compatibility it does not work and manual validation is required.

d)

It forces a user to fill text on the text field or text area before submitting the form. It is used for form validation.

43.

How to write HTML code dynamically using JavaScript?

a)

document.getElementById('some-div-id').innerHTML="<h2>This is heading using JavaScript</h2>";

b)

document.getElementById('some-div-id').innerHTML.val("<h2>This is heading using JavaScript</h2>";)

c)

document.getElementById('some-div-id').innerHTML.html("<h2>This is heading using JavaScript</h2>";)

d)

document.getElementByTagName('some-div-id').innerHTML="<h2>This is heading using JavaScript</h2>";

44.

What attribute/value do we use to make a button execute JavaScript when clicked?

a)

onclick="doSomething;"

b)

on-click="doSomething;"

c)

onclick="doSomething();"

d)

onclick=doSomething();

45.
Select the code below that uses CSS to configure a background color of #000000 for a web page.
a)
body { background-color: #000000; }
b)
body { bgcolor: #000000; }
c)
document { background­-page: #000000; }
d)
None of these
46.
Which CSS code is incorrect?
a)
a {color: blue;}
b)
p {font-size: 10px;}
c)
body {background-color="red";}
d)
img {width: 100%;}
47.
The code for the comment tag in CSS is
a)
<!-- comment -->
b)
<!-- comment >
c)
/* comment /*
d)
/* comment */