0% found this document useful (0 votes)
8 views

lesson3_Javascript_MCQ_&program

Uploaded by

gopaldixit9450
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

lesson3_Javascript_MCQ_&program

Uploaded by

gopaldixit9450
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Class :-12th Science Information Technology Teacher : Mrs.

Shilpa Kate

MCQ Questions : Lesson No.3::Advanced Javascript

Q1 Fill in the blanks

1. In Server-side scripting the script resides on web server.


2. JavaScript has a built-in multiway decision statement known as switch.
3. Iteration refers to the execution of statement or a group of statements of code for a fixed
number of times.
4. For loop combines initialization,condition and loop iteration in single statement.
5. Break statement is used to jump out of loop.
6. When it is necessary to skip statement block and take the control at the beginning for next
iteration Continue statement is used.
7. The new keyword is used to create new object in JavaScript.
8. An object can group data together with functions needed to manipulate it.
9. All tangible things are known as Objects.
10. DOM stands for Document Object Model.
11. Using getElementById() method id properly is used to find an element.
12. Window object is parent of all other objects.
13. Location property of window object returns the location object for the window.
14. The innerHTML property is useful for getting html element and changing its content.
15. Blur() method of window object removes focus from current window.
16. Onfocus event handler occures whenan element gets focus.
17. Onselect event handler occures when user clicks submit button.
18. charAt() method of string object returns the character at the specified position.
19. indexOf() method of string object returns the index of the first occurance of specified
character in given string
20. toLowerCase() method of string object converts a string to lower case.

Q2 True or false

1. Javascript cannot handle date and time


Ans:: False
2. Javascript is an object oriented scripting language.
Ans:: True
3. There should not be duplicity between the cases.
Ans:: True
4. Loop will execute statement in statements block will the condtion is false.
Ans:false
5. Break statement is used to jump out of loop.
Ans:: True
6. Continue statement is used to make early exit from a loop.
Ans:: false
7. Javascript is an entity having properties and objects.
Ans:: True

8.Properties and method of object are accessed with “.” Operator.

Ans:: True

9. onkeyPress,onKeyDown are keyboard events

Ans:: True
10.onfocus event handler occurs which an element gets focus.
Ans: True
11.length property returns the number of characters in a string.
Ans: True
12. NaN property of number of object returns Not a Number value
Ans: True

Q3 .Multiple choice question – 1 correct option

1.Javascript has a built-in multiway decision statement known as __________

a. condition

b.switch

c. break

d. continue

2. ….refers to the execution of statement or a group of statement or a group of statements of


code for a fixed number of times.

a. statement

b. .function

c. Method
d. Iteration

3……statement is used to jump out of loop.

a. Break

b. Respond

c. continue

d. react

4. What it is necessary to skip statement block and take the control at the beginning for next
iteration ……statement is used.

a. break

b. react

c. response

d. continue

5. The……keyword is used to create new object in Javascript.

a. Next

b.New

c.Wend

d. Loop

6. An….can group data together with together with functions needed to manipulate it.

a.Method

b.Function

c. Object

d.Response

7. All tangible things are known as

a.Objects

b.Method
c.function

d.variable

8…..property of DOM object returns URL of the HTML document

a.SRC

b. HREF

c. LINK

d. URL

9.Using ……method id property is useful for getting html element and changing its content.

a.write

b.URL

c.innerHTML

d.writeln

10………object represents an open window in browser

a.Window

b.Math

c.Array

d.String

11…….method of window object sets focus to the current window.

a.open()

b.blur()

c.close()

d.focus()

12…….event occurs when user leaves or looses focus of an element.

a)onblur

b)onchage
c)onfocus

d)onchange

13……event occurs when user clicks submit button.

a)onblur

b)onchange

c)onfocus

d)onsubmit

14……event occurs when page/image has been loaded

a)onblur

b)onload

c)onsubmit

d) onunload

Q4 .Multiple choice question Select 2 correct options:::

1.Types of loops in JavaScript are……

a. for…loop

b. while…loop

c. for….next

d. while…..wend

2. Correct method of for loop are….

a. for(i=1;i<=5;i++) b. for(i=1,i!=4);

{ {

document.write(i); document.write(i);

} }
c. for(i=1;i<=5;i++)

document.writeln(i);

3.Following are the properties of Document Object Model ……..

a. Src

b. head

c. URL

e. title

4.Following are the methodsof window object

a. write()

b. body

c. URL

d.writeln()

6. Following are the event handlers in JavaScript

a. onsubmit b. write()

c. writeln() d. onchange

7.Following properties of Number Object returns the largest minimum and maximum value

a. MIN_VALUE b. MAX_VALUE

c. toLowerCase() d. toUpperCase()

8. Following are the methods of string objects

a)charAt() b)width

c)length d) trim()
****************Javascript Programs*********************

1. Program to display Even numbers from 25 to 50. Using onclick event

Ans:

<html>

<head>

<script type="text/javascript">

function even()

var i;

document.write("<br> Even Numbers from 25-50 are <br>");

for(i=26;i<=50;i=i+2)

document.write("<br>"+i);

</script>

</head>

<body>

<input type="button" value="click Here" onClick="even()">

</body>

</html>
2.Program to display cube of any number

<!doctype html>

<html>

<head>

<script type="text/javascript">

function getcube()

var num;

num=document.getElementById("number").value;

alert(num*num*num);

</script>

</head>

<body>

<form>

Enter number :<input type="text" name="t1" id="number">

<input type="button" value="cube" onClick="getcube()">

</form>

</body>

</html>
3.DISPLAY MULTIPLICATION of two numbers, which were ACCEPTED from
user.

<!doctype html>

<html>

<head><title>Calculator using Javascript</title>

<script type="text/javascript">

var result=0;

function calc()

var n1=parseInt(f1.t1.value);

var n2=parseInt(f1.t2.value);

document.write("<br>Accepted Numbers are n1= "+n1+" & n2="+n2);

result=n1*n2;

document.write("<br>Multiplication is="+result);

</script>

</head>

<body>

<form name="f1">

Enter first Number:<input type="text" name="t1"><br><br>

Enter Second Number:<input type="text" name="t2"><br><br>

<input type="button" value="Calculator" onClick="calc()">

</form>

</body>

</html> <!doctype html>


4 .DISPLAY Table of 5

<html>

<head><title> Display table of 5</title>

<script type="text/javascript">

function display()

var i, num=5, res

document.write("Table of 5");

document.write("<Br>");

for(i=1;i<=10;i++)

res=num*i;

document.write(num+"*"+i+"="+res+"<BR>");

</script>

<body>

<h1> Table of number</h1>

<form>

<input type="button" value="clickhere" onClick="display()">

</form>

</body>

</html>

You might also like