Menu

Objective Type Questions & Answers


Web Technologies -Unit-5 (JavaScript) Objective Type Questions



1. What is the HTML tag under which one can write the JavaScript code?

A . <javascript>

B . <scripted>

C . <script>

D . <js>

Answer


2. Choose the correct JavaScript syntax to change the content of the following HTML code.
<p id="msg">Welcome</p>

A . document.getElement("msg").innerHTML="Welcome to JavaScript";

B . document.getElementById("msg").innerHTML="Welcome to JavaScript";

C . document.getElementById("msg").innerHTML=Welcome to JavaScript;

D . document.getId("msg").innerHTML="Welcome to JavaScript";

Answer


3. Which of the following is the correct syntax to display "Welcome" in an alert box using JavaScript?

A . alertbox("Welcome");

B . msg("Welcome");

C . msgbox("Welcome");

D . alert("Welcome");

Answer


4. What is the correct syntax for referring to an external script called "sample.js"?

A . <script src="sample.js">

B . <script href="sample.js">

C . <script ref="sample.js">

D . <script name="sample.js">

Answer


5. Predict the output of the following JavaScript code.
<script type="text/javascript"> 
a = 8 + "8"; 
document.write(a); 
</script> 

A . 16

B . Complilation Error

C . 88

D . Run Time Error

Answer


6. Predict the output of the following JavaScript code.
<script type="text/javascript"> 
var a="WebTechnology"; 
var x=a.lastIndexOf("e"); 
document.write(x); 
</script> 

A . 1

B . 5

C . 4

D .  Error

Answer


7. Predict the output of the following JavaScript code.
<script type="text/javascript" language="javascript">   
var a = "WebTechnology"; 
var result = a.substring(3,4); 
document.write(result);   
</script> 

A . bTec

B . Tech

C . Te

D . bT

Answer


8. Predict the output of the following JavaScript code.
<script type="text/javascript" language="javascript">   
var x=5; 
var y=6; 
var res=eval("x*y"); 
document.write(res);   
</script> 

A . "30"

B . 30

C . 5*6

D . "5*6"

Answer


9. What is the correct syntax for adding comments in JavaScript?

A . <!–This is a comment–>

B . //This is a comment

C . –This is a comment

D . **This is a comment**

Answer


10. How to initialize an array in JavaScript?

A . var Items= “Item1”, “Item2”, “Item3”

B . var Items=(1:Item1, 2:Item2, 3:Item3)

C . var Items=(1=Item1, 2=Item2, 3=Item3)

D . var Items=[“Item1”, “Item2”, “Item3”]

Answer


11. What will be the command to print the number of characters in the string “JavaScript”?

A . document.write(“JavaScript”.len);

B . document.write(sizeof(“JavaScript”));

C . document.write(“JavaScript”.length);

D . document.write(lenof(“JavaScript”));

Answer


12. JavaScript is a ________ Side Scripting Language.

A . Server

B . ISP

C . Browser

D . None of the above

Answer


13. Predict the output on the console for the following JavaScript code.
<script> 
      
    function display() { 
    if(true) { 
        var a = 5; 
    } 
    document.write(a); 
} 
display();                     
  
</script> 

A . Compilation Error

B . 5

C . Nothing will be printed as output

D . Runtime error

Answer


14. How do you round the number 7.25, to the nearest integer?

A . round(7.25)

B . Math.round(7.25)

C . math.round(7.25)

D . rnd(7.25)

Answer


15. How do you find the number with the highest value of x and y?

A . Math.ceil(x,y)

B . Math.top(x,y)

C . ceil(x,y)

D . Math.max(x,y)

Answer


16. Which event occurs when the user clicks on an HTML element?

A . onchange

B . onclick

C . onsubmit

D . onload

Answer


17. How to write an IF statement for executing some code if "i" is NOT equal to 5?

A . if(i<>5)

B . if i!=5 then

C . if(i!=5)

D . if i<>5

Answer


18. Integer Variable is declared using following syntax in JavaScript.

A . int num;

B . integer num;

C . var num;

D . num

Answer


19. Which of the following can be used to select HTML elements based on the value of their name attributes?

A . getElementByName()

B . getElementsByName()

C . getElementsName()

D . getElementName()

Answer


20. Which of the following is correct about features of JavaScript?

A . JavaScript is complementary to and integrated with HTML

B . JavaScript is open and cross-platform.

C . Both of the above.

D . All of the above

Answer




Relevant Materials :

Web Technologies -Unit-1 (PHP) Objective Type Questions - [ Web Technologies ]

Web Technologies -Unit-2 (XML) Objective Type Questions - [ Web Technologies ]

Web Technologies -Unit-3 (Servlets) Objective Type Questions - [ Web Technologies ]

Web Technologies -Unit-4 (JSP) Objective Type Questions - [ Web Technologies ]

Web Technologies -Unit-5 (JavaScript) Objective Type Questions - [ Web Technologies ]


Similar Materials :

R - Programming MCQs - Unit-1 - [ R-Programming ]

R - Programming MCQs - Unit-2 - [ R-Programming ]

R - Programming MCQs - Unit-3 - [ R-Programming ]

R - Programming MCQs - Unit-4 - [ R-Programming ]

R - Programming MCQs - Unit-5 - [ R-Programming ]

Formal Languages and Automata Theory (FLAT) MCQs - Unit-1 - [ FLAT ]

Formal Languages and Automata Theory (FLAT) MCQs - Unit-2 - [ FLAT ]

Formal Languages and Automata Theory (FLAT) MCQs - Unit-3 - [ FLAT ]

Formal Languages and Automata Theory (FLAT) MCQs - Unit-4 - [ FLAT ]

Formal Languages and Automata Theory (FLAT) MCQs - Unit-5 - [ FLAT ]

PPS MCQs - Unit-1 - [ PPS ]

PPS MCQs - Unit-2 - [ PPS ]

PPS MCQs - Unit-3 - [ PPS ]

PPS MCQs - Unit-4 - [ PPS ]

PPS MCQs - Unit-5 - [ PPS ]

Object Oriented Programming through Java MCQs - Unit-1 - [ OOP_JAVA ]

Object Oriented Programming through Java MCQs - Unit-2 - [ OOP_JAVA ]

Object Oriented Programming through Java MCQs - Unit-3 - [ OOP_JAVA ]

Object Oriented Programming through Java MCQs - Unit-4 - [ OOP_JAVA ]

Object Oriented Programming through Java MCQs - Unit-5 - [ OOP_JAVA ]

Design and Analysis of Algorithms MCQs - Unit-1 - [ DAA ]

Design and Analysis of Algorithms MCQs - Unit-2 - [ DAA ]

Design and Analysis of Algorithms MCQs - Unit-3 - [ DAA ]

Design and Analysis of Algorithms MCQs - Unit-4 - [ DAA ]

Design and Analysis of Algorithms MCQs - Unit-5 - [ DAA ]

Software Engineering MCQs - Unit-1 - [ SE ]

Software Engineering MCQs - Unit-2 - [ SE ]

Software Engineering MCQs - Unit-3 - [ SE ]

Software Engineering MCQs - Unit-4 - [ SE ]

Software Engineering MCQs - Unit-5 - [ SE ]

Data Mining MCQs - Unit-1 - [ DM ]

Data Mining MCQs - Unit-2 - [ DM ]

Data Mining MCQs - Unit-3 - [ DM ]

Data Mining MCQs - Unit-4 - [ DM ]

Data Mining MCQs - Unit-5 - [ DM ]

Computer Organization and Architecture (COA) Objective Question Bank-Unit-1 - [ COA ]

Computer Organization and Architecture (COA) Objective Question Bank-Unit-2 - [ COA ]

Computer Organization and Architecture (COA) Objective Question Bank-Unit-3 - [ COA ]

Computer Organization and Architecture (COA) Objective Question Bank-Unit-4 - [ COA ]

Computer Organization and Architecture (COA) Objective Question Bank-Unit-5 - [ COA ]

Data Structures Objective Type Question Bank-Unit-1 - [ DS ]

Data Structures Objective Type Question Bank-Unit-2 - [ DS ]

Data Structures Objective Type Question Bank-Unit-3 - [ DS ]

Data Structures Objective Type Question Bank-Unit-4 - [ DS ]

Data Structures Objective Type Question Bank-Unit-5 - [ DS ]

Database Management System Objective Type Question Bank-Unit-1 - [ DBMS ]

Database Management System Objective Type Question Bank-Unit-2 - [ DBMS ]

Database Management System Objective Type Question Bank-Unit-3 - [ DBMS ]

Database Management System Objective Type Question Bank-Unit-4 - [ DBMS ]

Database Management System Objective Type Question Bank-Unit-5 - [ DBMS ]