11. When the interpreter encounters empty statements, what it will do:
- Shows a warning
- Prompts to complete the statement
- Throws an error
- Ignores the statements
Answer : D Explanation: In JavaScript, when the interpreter encounters an empty statement it normally ignores or don’t respond to that empty statement. The empty statements also sometimes very useful like we use the empty statements for creating a loop for nothing.
12. Which of the following code creates an object?
- var book = Object();
- var book = new Object();
- var book = new Book();
- var book = new OBJECT();
Answer : B Explanation: var book = new Object(); will create an object.
13. JavaScript is designed for the following purpose:
- To style HTML pages
- To execute Queries related to databases on a server
- To add interactivity to html pages
- All of the above
Answer : D Explanation: JavaScript is designed for all of the following purposes: to style HTML pages, to execute Queries related to databases on a server, to add interactivity to HTML pages, to perform server side scripting operations, etc.
14. The meaning for augmenting classes is that
- objects inherit prototype properties in static state
- objects inherit prototype properties only in dynamic state
- objects inherit prototype properties even in dynamic state
- None of the mentioned
Answer : C Explanation: Objects inherit prototype properties even in dynamic state, JavaScript’s prototype-based inheritance mechanism is dynamic: an object inherits properties from its prototype, even if the prototype changes after the object is created. This means that we can augment JavaScript classes simply by adding new methods to their prototype objects and hence option C is correct.
15. What is the correct JavaScript syntax to write “Hello World”?
- System.out.println(“Hello World”)
- document.write(“Hello World”)
- println (“Hello World”)
- response.write(“Hello World”)
Answer : B Explanation: document.write(“Hello World”) is the correct JavaScript syntax to write “Hello World”.
16. How we write “Hello World” in an alert box?
- alertBox(“Hello World”);
- msgBox(“Hello World”);
- msg(“Hello World”);
- alert(“Hello World”);
Answer : D Explanation: alert(“Hello World”);
17. Why JavaScript is called as Lightweight Programming Language?
- because we can add programming functionality inside JS
- because JS is client side scripting
- because JS can provide programming functionality inside but up to certain extend
- because JS is available free of cost
Answer : C Explanation: JS is called as “Lightweight Programming Language” because it can include programming functionality but does not perform stronger operations like Java and C++.
18. To include external JS code inside an HTML document which attribute is used?
- src
- link
- script
- ext
Answer : A Explanation: To include external JS code inside an HTML document src attribute is used.
19. The “function” and ” var” are known as:
- Keywords
- Special keywords
- Declaration statements
- Prototypes
Answer : C Explanation: The “function” and “var” both are the Declaration statements and these both are used for defining, and declaring variable, functions anywhere in the program, and hence option C is correct.
20. Which of the following function of the String object returns the calling string value converted to upper case?
- toLocaleUpperCase()
- toString()
- substring()
- toUpperCase()
Answer : D Explanation: toUpperCase() function of the String object returns the calling string value converted to upper case.
Pingback: Data Structure MCQ Questions and Answers - cozmocard
Pingback: Computer Networks MCQ Questions And Answers - cozmocard
Pingback: Neural Networks MCQ Questions And Answers - cozmocard