JavaScript Essentials MCQs Solution | TCS Fresco PlayCourse Path: Modern Web Development/WEB BASICS/JavaScript Essentials
Disclaimer: The primary purpose of providing this solution is to assist and support anyone who are unable to complete these courses due to a technical issue or a lack of expertise. This website's information or data are solely for the purpose of knowledge and education.
Make an effort to understand these solutions and apply them to your Hands-On difficulties. (It is not advisable that copy and paste these solutions).
All Question of the MCQs Present Below for Ease Use Ctrl + F with the question name to find the Question. All the Best!
JavaScript Essentials Hands-on Solution
Quiz on Basics of JavaScript
1.______________ is used to display whether a value is a number or not.
- NaN
- isundefined
- isNan
- undefined
2.What is right about variables?
- Variables are case sensitive
- % is a valid first character for variable name
- ^US is a valid variable name
- 7Wonders is a valid variable name to
Answer: 1)Variables are case sensitive
3.What option would you specify when inserting the code script type="____" in a web page?
- text/language
- JavaScript/text
- text/JavaScript
Answer: 3)text/JavaScript
4.Is the given definition a valid variable definition? var 100apples
- No
- Yes
5.Which statement has the correct JavaScript syntax?
- console.log("text");
- document.write("text")
- alert stop ;
Answer: 1)console.log("text");
6.What is the ideal place to load the external JavaScript file in your HTML document?
- Anywhere within the body is good enough
- Towards the beginning of the body to load the page along with the JavaScript code
- Towards the end of the body to increase the performance of the webpage
Answer: 3)Towards the end of the body to increase the performance of the webpage
7.Is the given assignment a valid variable assignment? var product cost = 3.45;
- No, floating numbers are not allowed.
- No, there should be no space in the variable name.
- Yes, it is valid.
Answer: 2)No, there should be no space in the variable name.
8.JavaScript has to be called inside ________ tags.
- Either in body or head
- head
- script
- body
9.You wish to create an alert. Select the correct one from the following options.
- alert('goodbye");
- alert("goodbye');
- alert('he said "goodbye" ');
Answer: 3)alert('he said "goodbye" ');
1.Which one of the following options are not valid in JavaScript?
- "My name is "Harry" "
- "My name is Harry"
- My name is Harry'
- "My name is 'Harry' "
Answer: 1)"My name is "Harry" "
2.Code A: var x = 10; y = --x + 1;
alert(y);
Code B: var x = 10;
y = x-- + 1;
alert(y);
What is the output for code A and B?
- 10,11
- 11,11
- 11,10
- 10,10
3.isNan function returns ______ if the argument is not a number; otherwise it is ______.
- True, True
- False, False
- True, False
- False, True
4.What is the value of C here?
var a = 100; var b = "10"; var c = a + b;
- 10010
- 10100
- 110
- None
5.Multiple variables can be created and initialized in a single JavaScript statement.
- True
- False
6.Which statement will return the value false?
- var result = 30 >= 30;
- var result = (20 === "20") && (50 < 30);
- var result = 20 < 50;
Answer: 2)var result = (20 === "20") && (50 < 30);
1.________ pretest loop executes until the value of z equals 10.
- for (var z= 1; z < 10; z++) { alert (z); }
- do { ++z; } while (z < 10);
- while (z >10) { z--; }
Answer: 3)while (z >10) { z--; }
2.__ lets you loop through a code block as long as the named condition is true.
- For
- While
- Tag
3.________ is used to exit a loop early.
- Exit
- Continue
- Alert
- Break
Quiz on Objects1.In JavaScript, an object is a container of properties and functions. Properties are identified by ____ and behavior is identified by _____.
- variables, functions
- functions, variables
- attributes, variables
- attributes, functions
Answer: 1)variables, functions
2.In a multidimensional array mySubject, which of the following option will allow assigning the value 100 in position 5 of the third mySubject array?
- mySubject[5][3] = 100
- mySubject[2][4] = 100
- mySubject[4][2] = 100
- mySubject[3][4] = 100
- mySubject[3][5] = 100
Answer: 2)mySubject[2][4] = 100
3.To retrieve the day of the month from the Date object, which is the code to select?
- var date_obj = new Date(2016,1,1);
- month_date = date_obj.getMonth();
- month_day = date_obj.getDay();
- month_date = date_obj.toDateString();
- var month_day = date_obj.getDate();
Answer: 5)var month_day = date_obj.getDate();
4.Which is the correct way to create an array in JavaScript? I) var myProg = []; II) var myArray = ["C","Java","C++","Python"]; III) var myProg = new Array();
- I, II & III
- I, II
- I, III
- II, III
Answer: 1)I, II & III
5.What is true about an array?
Can have a combination of data types in a single array list.
Must have same data types for an array list.
Answer: 1)Can have a combination of data types in a single array list.
Q6.Can arrays in JavaScript be extended?
- No, they cannot be
- Yes, they can be.
- Maybe, they can be extended conditionally
Quiz on Functions
1.What is the output for the following code?
(function f(){
function f(){
return 1; }
return f();
function f()
{ return 2; } })();
- 2
- NaN
- 1
- Error
2.What is the output of the following expression?
function multi(x,y) {
var c = x*y;
}
multi(20,3);
- Nothing
- 20
- 3
- 60
3.Which of the following regarding scope is true?
- Data that is stored in a variable when a function is called is never cleared out.
- Function parameters are visible in the function in which they are used.
- All variables you use in your program have to be declared as global variables.
- Variables that have a local scope are only visible in the function in which they are declared.
Answer: 4)Variables that have a local scope are only visible in the function in which they are declared.
4.What is true about functions? I) Functions are objects II) Can be assigned to a variable III) Can be anonymous IV) Return value type has to be defined in a function declaration
- I, II, III, IV
- I, II, III
- I, II, IV
- I, II
5.Anonymous functions can be created in JavaScript. What do anonymous function do?
- Process a variable before passing it on to another function
- Overwrite variables that are to be kept updated
- Automatically define the scope of a value inside a parameter
Answer: 1)Process a variable before passing it on to another function
6.What is the output you get for the following code?
(function()
{
return typeof arguments; })
();
- array
- undefined
- object
- arguments
7.Object's properties are similar to variables and methods are similar to _________.
- Properties
- Operators
- Functions
- Conditionals
8.________ is a function contained within an object.
- None of the options
- Object
- Function
- Method
9.A function in JavaScript is an object. State if the statement is true or false?
- False
- True
10.What is the output for the following expression?
function test(x) {
while(x < 5)
{ x++; }
return x; }
alert(test(2));
- 2
- 3
- 6
- 5
1.For any structured document, __________ defines a standard set of objects.
- XML DOM
- HTML DOM
- Core DOM
2.Which statement about the name and id attributes of form fields is false?
- The id attribute is what is sent when the form is submitted.
- The name attribute can be used to access the field using getElementsByName().
- It is customary to give form fields both attributes, with the same value if possible.
- Either attribute may be omitted if it is unused.
Answer: 1)The id attribute is what is sent when the form is submitted.
3.Using HTML button tag, JavaScript command can be executed by using ____ function.
- "alert(Button1);"
- "alert('Button1');"
- "alert('Button1');
- "alert('Button");"
Answer: 2)"alert('Button1');"
4.By modifying the DOM, the contents on the page also gets modified
- True
- False
5.Document object is part of ____________ object.
- System
- Window
- Tree
6.Your div element in a document has id="answers". If a JS fn sets d=document.getElementById("answers"), then which is the preferred way to add a paragraph containing the word "Hello"? as a child of that div?
- answers.innerHTML = "Hello";
- d.appendChild("Hello ");
- d.innerHTML = "Hello ";
- p = createElement("p"); p.innerHTML = "Hello"; d.appendChild(p);
Answer: 4)p = createElement("p"); p.innerHTML = "Hello"; d.appendChild(p);
7.By modifying the DOM, the contents on the page also gets modified
- False
- True
8.Which statement accesses HTML classes?
- class.name
- getElementsByClassName
- getElementById
Answer: 2)getElementsByClassName
1.How many 'onload' events can be written in a page?
- 1
- Many
- None
- 2
2.Which is the most preferred way of handling events?
- Registering a listener to an element.
- Writing the JavaScript as an attribute to an element.
- Referencing an element with the event and assigning a function as a value.
Answer: 1)Registering a listener to an element.
Quiz on Javascript and AJAX
1.________ object is used to make calls and request data from server.
- XML
- XMLHttpRequest
- GET
2.AJAX requests can support data transfer in ______ format.
- None of the options
- XML
- JSON
- Any
3.The data from the AJAX request is usually in XML. State if the statement is true or false?
- False
- True
JS Final Assessment
1.What is true about array
- Can have combination of data types in a single array list
- Must have same data types for array list
Answer: 1)Can have combination of data types in a single array list
2.By modifying the DOM, the contents on the page also gets modified.
- False
- True
3.What option would you specify when inserting the code in a web page?
script type="____"
- text/language
- text/JavaScript
- JavaScript/text
Answer: 2)text/JavaScript
4.____ allows you to loop through a block of code as long as the specified condition is true.
- Tag
- While
- For
5.In multidimensional array mySubject, which of the following will allow assigning the value 100 in position 5 of the third mySubject array?
- mySubject[3][5] = 100
- mySubject[4][2] = 100
- mySubject[3][4] = 100
- mySubject[5][3] = 100
- mySubject[2][4] = 100
Answer: 5)mySubject[2][4] = 100
6.___________ is a pretest loop that will execute until the value of z equals 10.
- for (var z= 1; z < 10; z++) { alert (z); }
- do { ++z; } while (z < 10);
- while (z >10) { z--; }
Answer: 3)while (z >10) { z--; }
7.Is the following assignment a valid variable assignment?
`var product cost = 3.45;`
- No, there should be no space in the variable name.
- Yes, it is valid.
- No, floating numbers are not allowed.
Answer: 1)No, there should be no space in the variable name.
**************************************************
Credit for the above notes, goes to the respective owners.
If you have any queries, please feel free to ask on the comment section.
If you want MCQs and Hands-On solutions for any courses, Please feel free to ask on the comment section too.
Please share and support our page!
Post a Comment