Download our latest MNC Answers Application at Play Store. Download Now

JavaScript Essentials MCQs Solution | TCS Fresco Play


JavaScript Essentials MCQs Solution | TCS Fresco Play

Course 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.

  1. NaN
  2. isundefined
  3. isNan
  4. undefined

Answer: 3)isNan

2.What is right about variables?

  1. Variables are case sensitive
  2. % is a valid first character for variable name
  3. ^US is a valid variable name
  4. 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?

  1. text/language
  2. JavaScript/text
  3. text/JavaScript

Answer: 3)text/JavaScript

4.Is the given definition a valid variable definition? var 100apples

  1. No
  2. Yes

Answer: 1)No

5.Which statement has the correct JavaScript syntax?

  1. console.log("text");
  2. document.write("text")
  3. alert stop ;

Answer: 1)console.log("text");

6.What is the ideal place to load the external JavaScript file in your HTML document?

  1. Anywhere within the body is good enough
  2. Towards the beginning of the body to load the page along with the JavaScript code
  3. 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;

  1. No, floating numbers are not allowed.
  2. No, there should be no space in the variable name.
  3. Yes, it is valid.

Answer: 2)No, there should be no space in the variable name.

8.JavaScript has to be called inside ________ tags.

  1. Either in body or head
  2. head
  3. script
  4. body

Answer: 3)script

9.You wish to create an alert. Select the correct one from the following options.

  1. alert('goodbye");
  2. alert("goodbye');
  3. alert('he said "goodbye" ');

Answer: 3)alert('he said "goodbye" ');

JavaScript Essentials Hands-on Solution

Quiz on Operators

1.Which one of the following options are not valid in JavaScript?

  1. "My name is "Harry" "
  2. "My name is Harry"
  3. My name is Harry'
  4. "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?

  1. 10,11
  2. 11,11
  3. 11,10
  4. 10,10

Answer: 1)10,11

3.isNan function returns ______ if the argument is not a number; otherwise it is ______.

  1. True, True
  2. False, False
  3. True, False
  4. False, True

Answer: 3)True, False

4.What is the value of C here?

var a = 100; var b = "10"; var c = a + b;

  1. 10010
  2. 10100
  3. 110
  4. None

Answer: 1)10010

5.Multiple variables can be created and initialized in a single JavaScript statement.

  1. True
  2. False

Answer: 1)True

6.Which statement will return the value false?

  1. var result = 30 >= 30;
  2. var result = (20 === "20") && (50 < 30);
  3. var result = 20 < 50;

Answer: 2)var result = (20 === "20") && (50 < 30);

JavaScript Essentials Hands-on Solution

Quiz on Loops

1.________ pretest loop executes until the value of z equals 10.

  1. for (var z= 1; z < 10; z++) { alert (z); }
  2. do { ++z; } while (z < 10);
  3. 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.

  1. For
  2. While
  3. Tag

Answer: 2)While

3.________ is used to exit a loop early.

  1. Exit
  2. Continue
  3. Alert
  4. Break

Answer: 4)Break


Quiz on Objects

1.In JavaScript, an object is a container of properties and functions. Properties are identified by ____ and behavior is identified by _____.

  1. variables, functions
  2. functions, variables
  3. attributes, variables
  4. 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?

  1. mySubject[5][3] = 100
  2. mySubject[2][4] = 100
  3. mySubject[4][2] = 100
  4. mySubject[3][4] = 100
  5. 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?

  1. var date_obj = new Date(2016,1,1);
  2. month_date = date_obj.getMonth();
  3. month_day = date_obj.getDay();
  4. month_date = date_obj.toDateString();
  5. 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();

  1. I, II & III
  2. I, II
  3. I, III
  4. 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?

  1. No, they cannot be
  2. Yes, they can be.
  3. Maybe, they can be extended conditionally

Answer: 2)Yes, they can be.


JavaScript Essentials Hands-on Solution

Quiz on Functions

1.What is the output for the following code?

(function f(){
function f(){
return 1; }
return f();
function f()
{ return 2; } })();

  1. 2
  2. NaN
  3. 1
  4. Error

Answer: 1)2

2.What is the output of the following expression?

function multi(x,y) {
var c = x*y;
}
multi(20,3);

  1. Nothing
  2. 20
  3. 3
  4. 60

Answer: 1)Nothing

3.Which of the following regarding scope is true?

  1. Data that is stored in a variable when a function is called is never cleared out.
  2. Function parameters are visible in the function in which they are used.
  3. All variables you use in your program have to be declared as global variables.
  4. 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

  1. I, II, III, IV
  2. I, II, III
  3. I, II, IV
  4. I, II

Answer: 2)I, II, III

5.Anonymous functions can be created in JavaScript. What do anonymous function do?

  1. Process a variable before passing it on to another function
  2. Overwrite variables that are to be kept updated
  3. 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; })
();

  1. array
  2. undefined
  3. object
  4. arguments

Answer: 3)object

7.Object's properties are similar to variables and methods are similar to _________.

  1. Properties
  2. Operators
  3. Functions
  4. Conditionals

Answer: 3)Functions

8.________ is a function contained within an object.

  1. None of the options
  2. Object
  3. Function
  4. Method

Answer: 4)Method

9.A function in JavaScript is an object. State if the statement is true or false?

  1. False
  2. True

Answer: 2)True

10.What is the output for the following expression?

function test(x) {
while(x < 5)
{ x++; }
return x; }
alert(test(2));

  1. 2
  2. 3
  3. 6
  4. 5

Answer: 4)5

JavaScript Essentials Hands-on Solution

Quiz on DOM

1.For any structured document, __________ defines a standard set of objects.

  1. XML DOM
  2. HTML DOM
  3. Core DOM

Answer: 3)Core DOM

2.Which statement about the name and id attributes of form fields is false?

  1. The id attribute is what is sent when the form is submitted.
  2. The name attribute can be used to access the field using getElementsByName().
  3. It is customary to give form fields both attributes, with the same value if possible.
  4. 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.

  1. "alert(Button1);"
  2. "alert('Button1');"
  3. "alert('Button1');
  4. "alert('Button");"

Answer: 2)"alert('Button1');"

4.By modifying the DOM, the contents on the page also gets modified

  1. True
  2. False

Answer: 1)True

5.Document object is part of ____________ object.

  1. System
  2. Window
  3. Tree

Answer: 2)Window

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?

  1. answers.innerHTML = "Hello";
  2. d.appendChild("Hello ");
  3. d.innerHTML = "Hello ";
  4. 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

  1. False
  2. True

Answer: 2)True

8.Which statement accesses HTML classes?

  1. class.name
  2. getElementsByClassName
  3. getElementById

Answer: 2)getElementsByClassName

JavaScript Essentials Hands-on Solution

Quiz

1.How many 'onload' events can be written in a page?

  1. 1
  2. Many
  3. None
  4. 2

Answer: 1)1

2.Which is the most preferred way of handling events?

  1. Registering a listener to an element.
  2. Writing the JavaScript as an attribute to an element.
  3. 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.

  1. XML
  2. XMLHttpRequest
  3. GET

Answer: 2)XMLHttpRequest

2.AJAX requests can support data transfer in ______ format.

  1. None of the options
  2. XML
  3. JSON
  4. Any

Answer: 4)Any

3.The data from the AJAX request is usually in XML. State if the statement is true or false?

  1. False
  2. True

Answer: 1)False


JS Final Assessment

1.What is true about array

  1. Can have combination of data types in a single array list
  2. 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.

  1. False
  2. True

Answer: 2)True

3.What option would you specify when inserting the code in a web page?

script type="____"

  1. text/language
  2. text/JavaScript
  3. JavaScript/text

Answer: 2)text/JavaScript

4.____ allows you to loop through a block of code as long as the specified condition is true.

  1. Tag
  2. While
  3. For

Answer: 2)While

5.In multidimensional array mySubject, which of the following will allow assigning the value 100 in position 5 of the third mySubject array?

  1. mySubject[3][5] = 100
  2. mySubject[4][2] = 100
  3. mySubject[3][4] = 100
  4. mySubject[5][3] = 100
  5. 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.

  1. for (var z= 1; z < 10; z++) { alert (z); }
  2. do { ++z; } while (z < 10);
  3. while (z >10) { z--; }

Answer: 3)while (z >10) { z--; }

7.Is the following assignment a valid variable assignment?

`var product cost = 3.45;`

  1. No, there should be no space in the variable name.
  2. Yes, it is valid.
  3. No, floating numbers are not allowed.

Answer: 1)No, there should be no space in the variable name.


JavaScript Essentials Hands-on Solution

**************************************************
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!