Fill in the blanks.
(1) __________ script resides on server computer.
Answer : Server-Side
(2) __________ statement is used to jump out of loop.
Answer : Break
(3) ____________ defines logical structure of document.
Answer : DOM (Document Object Model)
(4) ___________ property of window object returns Boolean value indicating whether window is closed or not.
Answer : Closed
(5) ____________ event occurs when an element losses its focus.
Answer : onblur
State whether given statement is true or false.
(1) JavaScript is case sensitive language.
True
False
Answer : True
(2) Math.ceil() function is used to return the nearest integer less than or equal to given number.
True
False
Answer : False
(3) MAX_VALUE property of number object returns smallest possible value.
True
False
Answer : False
(4) getDay() method of Date object returns month in number.
OPTIONS
True
False
Answer : False
(5) onKeydown event occurs when user moves mouse pointer.
True
False
Answer : False
Multiple choice questions. Select one correct answer.
(1) JavaScript is ___________ language.
Compiled
Interpreted
Both Compiled and Interpreted
None of the above
Answer : Both Compiled and Interpreted
(2) Select correct method name of String object ________
charAt()
characterAt()
valueAt()
lengthAt()
Answer : charAt()
(3) __________ method displays message box with Ok and Cancel button.
Confirm()
Alert()
both Confirm() and Alert()
None of these
Answer : Confirm()
(4) We can declare all types of variables using keyword ____________
var
dim
variable
declare
Answer : var
(5) Trace output of following JavaScript code.
var str="Information Technology"; document.write(str.lastlndexOf("o");
OPTIONS
18
19
20
21
Answer : 20
Multiple choice questions. Select two correct answer.
(1) Valid two methods of Date object are ___________ and ___________
a) setTime()
b) getValidTime()
c) getTime()
d) setValidTime()
Answe : setTime() and getTime()
(2) Properties of document object are __________ and ___________
a) URL
b) title
c) name
d) status
Answer : URL and title
(3) __________ and ________ are event/event handler used with text object in JavaScript.
a) onBlur
b) onMove
c) onFocus
d) onAction
Answer : onBlur and onFocus
Multiple choice questions. Select three correct answers.
(1) Select three correct methods of window object __________, __________ and ___________
a) write()
b) alert()
c) writeln()
d) close()
e) open()
f) charAt()
Answer : alert(), close() and open()
(2) JavaScript features are __________, _________ and ____________
a) supports event based facilities
b) is platform dependent language
c) case insensitive scripting language
d) provide inbuilt objects
e) can handle date and time effectively
f) requires special software to run
Answer : upports event based facilities, provide inbuilt objects and can handle date and time effectively.
(3) Inbuilt objects in JavaScript are _______, ________ and ___________
a) Time
b) Date
c) Inheritance
d) Array
e) Number
f) function
Answer : Date, Array and Number
Explain the following.
(1) What are the similarities and differences between Client-side Scripting and Server-side Scripting?
Answer :
Client-side Scripting:
- It is used at the frontend which users can see from the browser.
- Client-side scripting does not need any server interaction.
- Client-Side scripting language involves languages such as HTML5, JavaScript, etc.
- Client-side scripting is used for validation purposes.
Server-side Scripting:
- It is used at the backend, where the source code is not visible or hidden in the client browser.
- When a server-side script is processed it communicates to the server.
- Server-side scripting language involves languages such as PHP, ASP.NET, Python, etc.
- Server-side scripting is useful in customizing the web pages and implements dynamic changes in the website.
(2) Briefly explain features of JavaScript.
Answer :
- JavaScript is light weight scripting language.
- No need of special software to run JavaScript Programs
- JavaScript is the object-oriented scripting language
- It can handle date and time very effectively.
- It is a case-sensitive language.
(3) Explain switch case conditional statement in JavaScript with example.
Answer :
JavaScript has a decision control statement known as switch. The switch statement test the value of given expression against the list of case values and when the match is found a block of statement associated with that case is executed.
Syntax of switch case is:
switch(expression)
{
case x:
//code block
break;
case y:
//code block
break;
default:
//code block
}
Write event driven JavaScript program for the following.
(1) Write event driven JavaScript program for the following.
Display Addition, subtraction, multiplication, division and remainder of two numbers, which were accepted from user.
Answer :
<html>
<script type="text/javascript">
var a,b,res;
a=parselnt(prompt("Enter First Number"));
b=parselnt(prompt("Enter Second Number"));
res=a+b;
document.write("<br><br>Addition is"+res);
res=a-b;
document.write("<br><br>Substraction is"+res);
res=a*b;
document.write("<br><br>Multiplication is"+res);
res=a/b;
document.write("<br><br>Division is"+res);
</script>
</html>
(2)
Write event driven JavaScript program for the following.
Display number sequence from 100 to 150 in following format.
(100, 101, 102, ............., 150)
Coding:
<html>
<script type="text/javascript">
var i;
document.write("<br>Numbers from 100-150 are <br>");
for(i=100;i<=150;i++)
{
document.write("\t"+i);
}
</script>
</html>
(3)
Write event driven JavaScript program for the following.
Find and display factorial of given number.
Answer :
Coding:
<html>
<script type="text/javascript">
var n=4,i,f=1;
for(i=n;i>= 1;i--)
{
f=f*i;
}
document.write("<br>Factorial of 4 is"+f);
</script>
</html>
(4)
Write event driven JavaScript program for the following.
Accept any string from user and count and display number of vowels occurs in it.
Answer :
Coding:
<html>
<script type="text/javascript">
var n,i,ch,cnt=0;
n=prompt("Enter a String");
for(i=0;i<n.length;i++)
{
ch=n.charAt(i);
if(ch=='a' | | ch==' A' | | ch=='e' | | ch='E' | | ch='i' | | ch=='i' | |
ch=='o' | | ch=='O' | | ch=='u' | | ch=='U')
{
cnt=cnt+1;
}
}
document.write("Number of vowels in string are"+cnt);
</script>
</html>
Match the following.
(1) Match the following.
Column A | Column B |
ceil() | Writes HTML expression or JavaScript code to a document |
floor() | Sets focus to current window. |
write() | Removes white spaces from both sides of string. |
focus() | Returns next integer greater than or equal to given number. |
trim() | Returns the next integer less than or equal to given number. |
Answer :
Column A | Column B |
ceil() | Returns next integer greater than or equal to given number. |
floor() | Returns the next integer less than or equal to given number. |
write() | Writes HTML expression or JavaScript code to a document |
focus() | Sets focus to current window. |
trim() | Removes white spaces from both sides of string. |
No comments:
Post a Comment