Which one of the following options is the correct output for the given code of javascript

I. This set of questions focuses on the statements in JavaScript

1) Which type of JavaScript language is ___

  1. Object-Oriented
  2. Object-Based
  3. Assembly-language
  4. High-level

Answer: B

Explanation: JavaScript is not a pure OOP's (object oriented programming) based languages such as PHP, java or many other languages, although it is an object-based language. It is not OOP's based language, because it doesn't have three basic properties of object-oriented programming languages, such as polymorphism, encapsulation, and inheritance.


2) Which of the following is the correct output for the following JavaScript code:

  1. 1
  2. Error
  3. 10
  4. 5

Answer: A

Explanation: The output of the above snippet code will be one because, first of all, the interpreter will search "obj" for the property (y). But it fails to find "obj" for property "y," so it chooses a value from outside the object, which is available within the given code.


3) Which one of the following also known as Conditional Expression:

  1. Alternative to if-else
  2. Switch statement
  3. If-then-else statement
  4. immediate if

Answer: D

Explanation: A conditional expression can only evaluate two things, which either true or false, that are purely based on the evaluation of the condition


4) Among the following given JavaScript snipped codes, which is more efficient:

Code A

Code B

  1. Code 1
  2. Code 2
  3. Both Code 1 and Code 2
  4. Cannot Compare

Answer: A

Explanation: Code 1 will be more efficient. In fact, the second code may encounter a runtime error because the value of "number" is never going to be equal to or less than one.


5) In JavaScript, what is a block of statement?

  1. Conditional block
  2. block that combines a number of statements into a single compound statement
  3. both conditional block and a single statement
  4. block that contains a single statement

Answer: B

Explanation: A block of statement can be understand as the set of the zero or more statements. In general, a block of statement has common definition "which combines one or a number of statements into a single statement for ease.


6) When interpreter encounters an empty statements, what it will do:

  1. Shows a warning
  2. Prompts to complete the statement
  3. Throws an error
  4. Ignores the statements

Answer: D

Explanation: In JavaScript, when the interpreter encounters a empty statements it normally ignores or not response to that empty statement. The empty statements also sometimes very useful like we use the empty statements for creating loop for nothing.


7) The "function" and " var" are known as:

  1. Keywords
  2. Data types
  3. Declaration statements
  4. Prototypes

Answer: C

Explanation: The "function" and "var" both are the Declaration statements. These both are used for defining, and declaring variable, function in anywhere in the program.


8) In the following given syntax of the switch statement, the Expression is compared with the labels using which one of the following operators?

  1. ===
  2. equals
  3. ==
  4. equals

Answer: A

Explanation: The strict comparison operator returns true only if the operand are of the same type and content matches. When the switch statement is executed, the value of the expression is calculated and compared to the case labels, and looks for a case whose expressions produce the same value after evaluations (where the comparison is determined by the === operator).


9) What will happen, if the following JavaScript code is executed?

  1. An error is displayed
  2. An exception is thrown
  3. The values of count variable are logged or stored in a particular location or storage
  4. The value of count from 0 to 9 is displayed in the console

Answer: C

Explanation: The function "console.log ()" used in the above function is one of the pre-defined functions of JavaScript. It takes values as arguments passed to it, and displays that value in arguments inside the console when the code is executed.


10) Which of the following is the correct output for the following JavaScript code:

  1. 9
  2. 0
  3. 8
  4. Undefined

Answer: C

Explanation: The "if-else" is one of the conditional statements available in JavaScript like several other languages. Here the comparison performed in the "if" statement evaluates to false, so the instructions written in the else part gets executed. If the comparison performed in the "if" statement evaluates to true, then the instruction written in the if statement will be executed.


11) Which of the following is the correct output for the following JavaScript code:

  1. 10
  2. 9
  3. 8
  4. 0

Answer: C

Explanation: The code of the given program uses a switch statement, in which the value of the expression is compared with the available case labels. If the value matches with any case label, the code written corresponding to that case is executed otherwise the instruction written to the default is executed. Another important point is that switch statements are also used as an alternative to "if-else" statements to reduce the complexity and size of the code.


12) Which of the following is the correct output for the following JavaScript code:

  1. 10
  2. 6
  3. 33
  4. 0

Answer: B

Explanation: If we look at the given code carefully, we can see that here the "break" statement is not used after any of the case labels. Which means all the cases following "A" get executes if the following program is executed.


13) Which of the following is the correct output for the following JavaScript code:

  1. 3
  2. 0
  3. Error
  4. 2

Answer: B

Explanation: The "if-and if" statement is used to examine more than one condition. This is an extension of the "if-else" statement and is also known as the "if-else ladder". We can extend the "if-else" statement to check several conditions.


14) Which of the following is the correct output for the following JavaScript code:

  1. 10
  2. 17
  3. 18
  4. 0

Answer: D

Explanation: The switch case statement contains several cases in which the Default case also one of them. The default case only is get executed, when no other case matches with the expression's value.


II. This set of questions focuses on the variables in JavaScript

15) Which of the following variables takes precedence over the others if the names are the same?

  1. Global variable
  2. The local element
  3. The two of the above
  4. None of the above

Answer: B

Explanation: In JavaScript, the local variable takes precedence over the global variable if the name of both local and global variables is the same.


16) Which one of the following is the correct way for calling the JavaScript code?

  1. Preprocessor
  2. Triggering Event
  3. RMI
  4. Function/Method

Answer: D

Explanation: The JavaScript code can be called simply by making the function call to the element on which the JavaScript code execution has to be run. There are several other ways to call JavaScript code such as submit, onclick, and onload, etc.


17) Which of the following type of a variable is volatile?

  1. Mutable variable
  2. Dynamic variable
  3. Volatile variable
  4. Immutable variable

Answer: A

Explanation: The variables whose value can be modified that kind of variable are known as Mutable variable. In the JavaScript, only arrays and objects are mutable but not the primitive values.


18) Which of the following option is used as hexadecimal literal beginning?

  1. 00
  2. 0x
  3. 0X
  4. Both 0x and 0X

Answer: D

Explanation: In general, the X and x both can be used to denote the hexadecimal values, so any integer literal that begins with either 0X or 0x denotes a hexadecimal number.


19) When there is an indefinite or an infinite value during an arithmetic computation in a program, then JavaScript prints______.

  1. Prints an exception error
  2. Prints an overflow error
  3. Displays "Infinity"
  4. Prints the value as such

Answer: C

Explanation: In the case, where the result of any arithmetic expression is beyond the largest represent-able number,JavaScript prints the infinity. Similarly, if the result of any numerical operation is beyond the largest negative number, JavaScript prints negative infinity.


20) In the JavaScript, which one of the following is not considered as an error:

  1. Syntax error
  2. Missing of semicolons
  3. Division by zero
  4. Missing of Bracket

Answer: C

Explanation: Yes, you heard right that division of any integer by zero is not an error in the JavaScript. It just prints the infinity as a result. However, there is an exception in JavaScript, dividing zero with zero will not have any defined number/value so, the result of this specific operation is a special value "Not a Number" (or NaN) and printed as NaN.


21) Which of the following givenfunctions of the Number Object formats a number with a different number of digits to the right of the decimal?

  1. toExponential()
  2. toFixed()
  3. toPrecision()
  4. toLocaleString()

Answer: B

Explanation: The "tofixed()" method formats the given number with a specific number of digits to the right of the decimal.


22) Which of the following number object function returns the value of the number?

  1. toString()
  2. valueOf()
  3. toLocaleString()
  4. toPrecision()

Answer: B

Explanation: The method " valueOf()" returns the value of the parameter that was passed in it.


23) Which of the following function of the String object returns the character in the string starting at the specified position via the specified number of characters?

  1. slice()
  2. split()
  3. substr()
  4. search()

Answer: C

Explanation: The method " Subtr()" in the javascript is used to return the characters in the string starting at the specified position via the specified number of the characters.


24) In JavaScript the x===y statement implies that:

  1. Both x and y are equal in value, type and reference address as well.
  2. Both are x and y are equal in value only.
  3. Both are equal in the value and data type.
  4. Both are not same at all.

Answer: C

Explanation: The "===" statement are called strict comparison which only gets true only if the type and content of both the operand are strictly same.

Program

Output


25) Choose the correct snippet from the following to check if the variable "a" is not equal the "NULL":

  1. if(a!==null)
  2. if (a!)
  3. if(a!null)
  4. if(a!=null)

Answer: A

Explanation: The "==" is only true if the type and the content of both operands are the same. The "==" is also one of the common abstracts used for comparing two operands to check whether they are equal or not but it will notcheck the data type of the variables. So, the "! ==" operator is known as "non-equal", which is used in our case, to compare 0 to NULL. It obtains the output either as true or false that totally depends on the given conditions.


26) Suppose we have a text "human" that we want to convert into string without using the "new" operator. Which is the correct way from the following to do so:

  1. toString()
  2. String(human)
  3. String newvariable="human"
  4. Both human.toString() and String(human)

Answer: D

Explanation: There are three common ways to convert the text into strings:value.toString(),"" + value and String(value). We can convert a text to string without using "new" operator that are: human.tostring() and the another one is String(human).


27) See the given code of JavaScript and choose the correct output from the following:

  1. compilation error
  2. false
  3. runtime error
  4. true

Answer: D

Explanation: The "==" operatorconverts the both operand to the same type in case they both are of different datatype and perform comparison. A strict comparison will give true as output only when the content and the data type of both operands are same.


28) What will be the output of the following JavaScript code?

  1. True
  2. false
  3. runtime error
  4. compilation error

Answer: A

Explanation: The "===" is known as a strict comparison operator which will result as true when the data-type, content of operand are the same. For example, In JavaScript, two strings can be considered as strict equal when the length, sequence, and same characters, are the same when compared to each other.


29) Find out the correct output of the following given piece of code from the given options:

  1. logical error
  2. false
  3. runtime error
  4. true

Answer: D

Explanation: We can convert a non-string "integer " into a string by using the ".tostring()" method. The "===" (or we can say strict comparison) results in true only when, the content and the data-type of the operands are the same. So that's why the output of the above-given code will be obtained as true.


III. This set of questions focuses on operators and expressions of JavaScript

30) See the given code of JavaScript and choose the correct output from the following:

  1. 4090
  2. 90
  3. 4050
  4. Exception

Answer: C

Explanation: In JavaScript, the alert method does the typecasting and converts the value of the variable "valueinit" to a string after that it concatenates both of the strings and displayed them on the screen. So, here the correct output would be 4050.


31) In JavaScript, what will be used for calling the function definition expression:

  1. Function prototype
  2. Function literal
  3. Function calling
  4. Function declaration

Answer: B

Explanation: A function definition expression is a kind of "function literal' just like as the object initializer is a kind of "object literal". The function definition expression (or we can say a function literal) consists of the keyword Function, followed by the set of identifiers(or parameters names) that are separated by commas inside the parenthesis, and a small block of JavaScript code(which we normally called function body/definition) enclosed in the curly braces.


32) Which of the following one is the property of the primary expression:

  1. Contains only keywords
  2. basic expressions containing all necessary functions
  3. contains variable references alone
  4. stand-alone expressions

Answer: D

Explanation: In JavaScript, the primary expressions also called simplest expressions are those standalone expressions, which do not include any of the simpler expressions. The variable, constant or literal values and certain language keywords are the basic examples of the primary expressions.


33) Consider the following snippet of JavaScript code:

Which one of the following statement is most suitable to check if the pattern matches with the sting "text".

  1. test(text)
  2. equals(pattern)
  3. test(pattern)
  4. text==pattern

Answer: D

Explanation: The given pattern is applied on the string "text" enclosed in the parenthesis.


34) Which one of the following is used for the calling a function or a method in the JavaScript:

  1. Property Access Expression
  2. Functional expression
  3. Invocation expression
  4. Primary expression

Answer: C

Explanation: The invocation expression is one of the JavaScript's syntax which is used for making a function call or calling a method. It always starts with the function expression which identifies the certain function to be called or executed.


35) The "new Point(3,2)", is a kind of _______ expression

  1. Object Creation Expression
  2. Primary Expression
  3. Invocation Expression
  4. Constructor Calling Expression

Answer: A

Explanation: The object creation expression creates a new object and also invokes a method called constructor in order to initialize the properties of that object. The object creation expressions are just like the invocation expressions except that they prefixed with a keyword commonly known as New.


36) Which one of the following operator is used to check weather a specific property exists or not:

  1. Exists
  2. exist
  3. within
  4. in

Answer: D

Explanation: In JavaScript, the "in" operator is used to check if a specific property exists. The "in" operator is commonly used in looping statements to traverse array and objects as well.


37) Which one of the following is an ternary operator:

  1. ?
  2. :
  3. -
  4. +

Answer: A

Explanation: In JavaScript, only one ternary operator is supported, known as the conditional operator, which combines three different expressions into one expression. However, the conditional operator can also be used in place of the "if else" statements as well.


38) "An expression that can legally appear on the left side of an assignment expression." is a well known explanation for variables, properties of objects, and elements of arrays. They are called_____.

  1. Properties
  2. Prototypes
  3. Definition
  4. Lvalue

Answer: D

Explanation: The term "lvalue" is one of the historical terms which states that "an Expression that can appear legally on the left-side of the Assignment Expression". The properties of objects, elements, and variables are lvalues in JavaScript.


39) Which of the following is the correct output for the following JavaScript code:

  1. False
  2. True
  3. Runtime error
  4. Compilation error

Answer: B

Explanation: In the following JavaScript code, the "?" is being used which is also known as ternary operator". Here it is used to choose one option as a choice among the given two options. However, it is often used to write shorter and simple code because it can be used in the place of "if else" statements.


40) Which one of the following is correct output for the following given JavaScript code:

  1. Error
  2. Undefined
  3. 12
  4. 20

Answer: C

Explanation: In the above given JavaScript code, the "in" operator is used which checks (or performs search) for the specific property. If the certain property is found it returns true otherwise it returns false.


41) Which one of the following is correct output for the following given JavaScript code:

  1. 123.56
  2. Taller
  3. 190
  4. Little shorter

Answer: B

Explanation: In the above given code, the ternary operator is used that works on the 3 operands. The statement in the following code, initialize the type variable with value "little shorter" that is returned through the function.


42) Which one of the following is correct output for the following given JavaScript code:

  1. Good
  2. Evening
  3. GooodEvening
  4. undefined

Answer: C

Explanation: The alert method is commonly used for Displaying the value(or message) passed as argument in the "dialogbox" in the web-browser. Here, the alert method concatenates both given strings and prints as a single string in the form of output.


43) Which one of the following is correct output for the following given JavaScript code:

  1. Error
  2. clean:Italy
  3. clean:India
  4. undefined

Answer: C

Explanation: In the following given code, the "?" ternary operator is used for comparing the values and place is determined (or initialized) according to the true condition that whether it returns true (1) or false (0).


44) Which one of the following is correct output for the following given JavaScript code:

  1. 7
  2. -7.25
  3. 25
  4. -7

Answer: C

Explanation: In the following code, the method "abs ()" is used which returns absolute numbers as output hence the correct option is c. In JavaScript, the "abs ()" method is one of the methods stored in the library called Math's.


45) Which one of the following is correct output for the following given JavaScript code:

  1. 972
  2. 81
  3. 9
  4. Error

Answer: A

Explanation: Here the code above uses the "cbrt ()" method, which returns the cube root of the number passed in parentheses as an argument. The "cbrt()" method is one of the several methods that are found in the library called math's available in the JavaScript.


46) Which one of the following is correct output for the following given JavaScript code

  1. 01
  2. 4
  3. 00
  4. 047

Answer: D

Explanation: The method "acos()" used in the above code returns the arccosine of any number passed in it as an argument. The returned value lies in between 0 and PI radians if the passed value exceeds the limit from -1 to 1, the "acos()" methods returns the NaN(also known as Not a Number).


47) What we will get if we compare the "one" with "8" using the less than operator ("one"<8)?

  1. False
  2. True
  3. NaN
  4. Undefined

Answer: A


48) Which one of the following is known as the Equality operator, which is used to check whether the two values are equal or not:

  1. =
  2. ===
  3. ==
  4. &&

Answer: C

Explanation: The "==" called the equality operators, it returns true if both the value are equal otherwise it returns false.


49) Which one of the following operator returns false if both values are equal?

  1. !
  2. !==
  3. !=
  4. All of the above

Answer: C

Explanation: The "!=" operators returns false if both the given values are equal.


50) In a case, where the value of the operator is NULL , the typeof returned by the unary operator is___.

  1. undefined
  2. string
  3. boolean
  4. object

Answer: D

Explanation: In all cases, where the operator's value is NULL, then unary operator always returns the typeof object.


51) Check whether the following given statements for the Strictly equal operator are true or false:

a) If the data type of two values are equal, they are Equal.

b) If both values are undefined and both are null, they are Equal.

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

Answer: A

Explanation: The first statement does not follow the properties of strictly equal (===)operator, but second statement follows.


52) Which one of the following is correct output for the following javascriptcode:

  1. Letsfindout 40
  2. 40
  3. Letsfindout40
  4. Exception

Answer: C

Explanation: In JavaScript, the alert method does the typecasting and converts the value of the variable "valueinit" to a string after that it concatenates both of the strings and displayed them on the screen.


53) Which one of the following is not a keyword:

  1. if
  2. with
  3. debugger
  4. use strict

Answer: D

Explanation: The "use strict" is a type of directive which was introduced in ECMAScript5 and as we all know that directives are not the statements because they do not include any language keywords.


54) Which one of the following symbol is used for creating comments in the javascript:

  1. \\
  2. //
  3. \* *\
  4. \* */

Answer: B

Explanation: The single line comments always starts by the "//" and any text written in between the "// "and the end of the line is considered as comment and ignored by the JavaScript.


IV. This set of questions focuses on "Loop" statements in JavaScript

55) Which of the following is the correct output for the following JavaScript code:

  1. Prints the numbers in the array in the reverse order
  2. Prints the numbers in the array in specific order
  3. Prints "Empty Array"
  4. Prints 0 to the length of the array

Answer: B

Explanation: As we all know, the "do-while" statement creates a loop that runs at least once even if the given condition is not satisfied. This is because it runs for the first time before checking the condition, and then executes until the condition becomes false. Therefore, it traverses the array and prints the element of the array on the screen in a specific order.


56) Which one of the given code will be equivalent for the following JavaScript code:

a) Code A

b) Code B

C) Code C

d) Code D


Answer: A

Explanation: The variable in the code A working same ( e.g. traversing the array from the 0 index value) just like it working in the above code. In addition, we can also use the "For-in" loop statement for performing the same task more efficiently.


57) What are the three important manipulations for a loop on a loop variable?

  1. Updation, Incrementation, Initialization
  2. Initialization, Testing, Incrementation
  3. Testing, Updation, Testing
  4. Initialization, Testing, Updation

Answer: D

Explanation: In the "For" loop statement, the Initialization, Testing, and Updating(and in the same order) are the most significant manipulations. First of all, the Initialization of the variable is done, then the condition gets tested, and after executing the code written in between curly braces, variable's value gets incremented.


58) If the following piece of JavaScript code is executed, will it work if not, what kind of possible error can occur?

  1. Yes, it will work fine
  2. No, this will not iterate at all
  3. No, it will throw an exception as only numeric's can be used in a for loop
  4. No, it will produce a runtime error with the message "Cannot use Linked List"

Answer: A

Explanation: In the above-given code, the For loop statement is used for traversing the linked list data structure, which returns the last element of the list. So it is definitely going to work without throwing any exception.


59) What is the role of the "continue" keyword in the following piece of JavaScript code?

  1. The continue keyword restarts the loop
  2. The continue keyword skips the next iteration
  3. The "continue" keyword breaks out of the loop
  4. It is used for skipping the rest of the statements in that particular iteration

Answer: D

Explanation: The continue keyword does not get exit from the loop just like break keyword does. It skips the upcoming statements in that iteration form where it gets encountered, and instead of exiting the loop, it moves to the next iteration.


60) Which one of the following is not considered as "statement" in the JavaScript?

  1. use strict
  2. debugger
  3. if
  4. with

Answer: A

Explanation: In JavaScript, the "use strict" is not a keyword because it not includes any language keywords. However, it is a directive that is introduced in the ECMAscript5 version of the javascript. The "use strict" can be used only in the beginning of the script or in the beginning of the function where no actual keywords are mentioned yet.


61) What if we define a "for" loop and it removes one of the properties that has not yet been enumerated?

  1. The removed property will be stored in a cache
  2. The loop will not run at all
  3. That property will be enumerated
  4. That specific property will not be enumerated

Answer: D

Explanation: If the body of the "for" loop removes any of the property that has been not enumerated yet, normally that property not gets enumerated. If the object of the "for" loop statement creates a new property on the object, that property is usually not enumerated.


62) Which of the following is the correct response by the interpreter in a jump statement when an exception is thrown?

  1. The interpreter will jump to the one of the nearest enclosing exception handler
  2. The interpreter will throw another exception
  3. The interpreter will stop working
  4. The interpreter throws an error

Answer: A

Explanation: In the jumping statement, when an exception is thrown, the interpreter jumps to the closest enclosing exception handler, which may possibly exist in the same function.


63) Which one of the following is the possibly correct output for the given JavaScript code?

  1. 5
  2. 555
  3. 55
  4. error

Answer: C

Explanation: In the "for" loop statement, first of all, the variable's initialization takes place and checks the condition of the given expression. After that, the statements written in the body of the "for" loop statement are executed. The value of the variable gets incremented after each iteration until the condition gets false.


64) Which one of the following is the correct output for the given JavaScript code?

  1. 136
  2. 123
  3. 013
  4. 01

Answer: A

Explanation: In the "while" loop statement, the condition is first checked before executing the statements written in the loop's body. Generally, the value of the counter variable incremented at the end of the body of the "while" loop, whereas the statements are executed first.


65) Which of the following options would be the correct output for the given JavaScript code?

  1. 5555
  2. 5321
  3. 531
  4. 531-1-3

Answer: D

Explanation: The value of variable x will decrease 2 times when the loop body executes and the body will execute 4 times until the variable's value of j is 0.

Output

Which one of the following options is the correct output for the given code of javascript


66) Which of the following options would be the correct output for the given JavaScript code?

  1. 10
  2. error
  3. 4
  4. 5

Answer: A

Explanation: The variable's value will increase until it gets equal to 10, then the control will exit the loop's definition. There are no other statements to be executed in the definition of the loop,only the value of the variable "x" will be incremented, and the output will be 10.


67) Consider the following piece of JavaScript code:

What is the role of the "debugger" statement?

  1. It is kind of keyword which is used to debug the entire program at once
  2. It will do nothing, although it is a breakpoint
  3. It will debug the error in that statement
  4. All above mentioned

Answer: B

Explanation: A program can contain a number of mistakes like syntax errors, logical errors, etc, and for many of them, there are no alert messages and also no indications to find the mistakes. So, to find the location of the error and to correct that, developer setups the breaking points at the doubted code using the debugger window.


V. This set of questions focuses on serialization and object attributes in JavaScript

68) Which one of the following is the correct output for the given JavaScript code?

  1. 12
  2. error
  3. true
  4. false

Answer: D

Explanation: Object.preventExtensions () only prevents adding new properties that have ever been added to an object. This change is not reversible, meaning that once an object becomes non-extensible, it cannot be changed to an extensible.


69) Which one of the following is the correct output for the given JavaScript code?

  1. Runtime error
  2. 20
  3. 15
  4. Compilation error

Answer: C

Explanation: The object.freeze () method is used to "freeze" the properties of an object and also avoids adding new properties to it. This avoids manipulation/change in all existing values, properties, and attributes


70) Which one of the following is the correct output for the given JavaScript code?

  1. False
  2. true
  3. 20
  4. error

Answer: A

Explanation: In JavaScript, the "Object.is() method is one of the built-in methods. This method is used to know whether two values are the same or not. There is also a specific pre-defined method that compares the values and it returns a Boolean value as the result, which indicates whether two arguments are the same or not.


71) What will be the output of the following JavaScript code?

  1. true 21
  2. true false
  3. false false
  4. true true

Answer: D

Explanation: In JavaScript, "Object.getOwnPropertDescriptor()" provides the ability to query information about a property in detail. It returns a property's descriptor for that property, which directly presents on an object and not present in the object's prototype of the certain object.


72) Which one of the following is the correct output for the given JavaScript code?

  1. 0
  2. 1
  3. 2
  4. Error

Answer: C

Explanation: The method "Object.getOwnPropertySymbols()" used in the above program, returns a whole array of symbol properties, that are directly found on an object. In general, it returns an empty array, unless we have already set symbol properties on the object.


73) What is the basic purpose of the "toLocateString()" method?

  1. It returns a localised object representation
  2. It returns a localized string representation of the object
  3. It return a local time in the string format
  4. It return a parsed string

Answer: B

Explanation: The "ToLocatestring ()" method is one of the pre-defined methods of JavaScript, which returns the localized string representation of the object. For example the "date.toLocaleSting is also one of the predefined functions of the javascript that is used for converting time and date into a string.


74) What kind of work is being performed in the following given part of JavaScript's code?

  1. Object Encapsulation
  2. Object Encoding
  3. Object Abstraction
  4. Object Serialization

Answer: D

Explanation: In the above give piece of code, the task of Object Serialization is being performed. In this task, the object's state converted into a string, that also can be restored if needed. Another method used in the above-given code is "JSON.parse()", which parses a JSON string, object described by the string or constructing javascript value.


75) A set of unordered properties that, has a name and value is called______

  1. String
  2. Array
  3. Serialized Object
  4. Object

Answer: D

Explanation: The Objects in the JavaScript are considered as a set of unordered related data(or properties), reference types, in the form of "key: value" pairs. Hence each of the property contains a name and value.


76) A collection of elements of the same data type which may either in order or not, is called _____.

  1. String
  2. Array
  3. Serialized Object
  4. Object

Answer: B

Explanation: An array is a collection of different elements that are of the same data-type. It can place elements in ascending order, in descending order or random order. We can interpret it as a container that contains data items of the same data-type.


77) Every object contains three object attributes that are _______.

  1. Prototype, class, object's extensible flag
  2. Prototype, class, objects' parameters
  3. Class, parameters, object's extensible flag
  4. Native object, Classes and Interfaces and Object's extensible flag

Answer: A

Explanation: In general, each object contains three object associated attributes:

Object prototype: It is kind of reference/indication to another object from which properties are inherited.

Object class: It is a kind of string which classifies the type an object.

Object's extensible flag: It simply specifies that whether some new properties are added to the object.


78) What will be the output of the following JavaScript code?

  1. Properties
  2. property names
  3. property values
  4. objects

Answer: B

Explanation: In the above-given code, a nested object (an object inside in the other object) is used, and "firstname","lastname" are the properties. The value of that individual property is itself an object.


79) The linkage of a set of prototype objects is known as______

  1. prototype stack
  2. prototype
  3. prototype class
  4. prototype chain

Answer: D

Explanation: Suppose, A Time.prototype inherits some properties from the Object.prototype,So a Time Object created by using new Time() holds properties from both the object Time.prototype and Object.prototype. Hence this connected series of prototype object is known as prototype's chain.


80) In the following line of code, what we will call the "datatype" written in brackets?

  1. An String
  2. A integer
  3. An object
  4. Floating point

Answer: A

Explanation: In the above-given line of code, the value within the square brackets is used for accessing the property of that object. While using square brackets, the expression always evaluates to the string, or in the form of a value that is converted into a string.


81) To know about an object, whether the object is a prototype (or a part of a prototype chain) of another object, the user can use_______

  1. ==operator
  2. equals() method
  3. === operator
  4. isPrototypeOf() method

Answer: D

Explanation: The prototype is a kind of global property that is available with nearly all objects. In order to know about an object, whether the object is a prototype (or a part of a prototype chain) of another object, the user can use the "isPrototypeOf()" method. For example, if the user wants to find out about z whether it is a prototype of "s" or not, user can write z.isPrototypeOf(s).


82) In the following given line of code, the prototype representing the_____

  1. Function x
  2. Prototype of a function
  3. A custom constructor
  4. Not valid

Answer: B

Explanation: In general, every object instance has a unique property which indicates the constructor function that created it. A "custom" constructor is a kind of constructor that not needed any argument (or we can say constructor without argument) and it is created by the compiler automatically at the time of object creation if it is not created by user.


VI. This set of questions focuses on Arrays in JavaScript

83) What will be the output obtained by "shift ()" in the given code of JavaScript?

  1. Exception is thrown
  2. [4,5]
  3. [3,4,5]
  4. 5

Answer: D

Explanation: In JavaScript, the "unshift()"," shift()" methods work like just as push() and pop() but with a slight change, unlike the push and pop the unshift(), unshift() both insert and remove a data item from the beginning instead of from the end of the array. The "unshift()" is used for inserting the data element/item in the beginning of the array while the "shift()" method shifts the data item to the beginning of the array from the higher index, empty the last index of the array and returns the updated length of the array.

In the process of shifting, the data element is removed from the beginning of the array, and all subsequent elements are shifted and the new length of the array is returned.


84) Which one of the following options is the correct output for the given code of java script?

  1. 70
  2. 75
  3. 482
  4. error

Answer: C

Explanation: The "forEach()" method used in the above given code is one of the built-in method of JavaScript. This method traverses the whole array just like we use the "for" loop to traverse the array. The term traverse is referred to "going or accessing each element of the array at least one time".


85) Which one of the following options is the correct output for the given code of JavaScript?

  1. One
  2. two
  3. three
  4. error

Answer: C

Explanation: The "shift()" method used in the given code is one of the predefined method in JavaScript. This method is used to remove the data elements from the beginning and return it along with the new length of array. We can say that the "shift()" method works like the "pop" method except it removes the data element from the starting of array unlike the "pop" which removes from the end of the array.


86) Which one of the following options is the correct output for the given code of JavaScript?

  1. 1, 2, 3,4
  2. 4, 3, 2, 1
  3. 3
  4. 1

Answer: B

Explanation: The "reverse()" method used in the above given code is one of the predefined methods of the JavaScript, which is used to shift the data elements of an array in a reverse order.


87) Which one of the following options is the correct output for the given code of javascript?

  1. Error
  2. 5, 6, 7
  3. 4, 5, 6,
  4. 4, 5, 6, 7

Answer: A

Explanation: The "slice()" method used in the above program a built-in function of the JavaScript and it is used to delete/remove the data items from the array. In general, it requires two arguments,in which first one for starting point and another one for the ending point. For example, consider the following given code:

Output

Lemon,Apple

However, we can see that in given question only one argument is passed, so it will definitely result in an error.


88) Which one of the following method or operator is used for identification of the array?

  1. Typeof
  2. ==
  3. ===
  4. isarrayType()

Answer: D

Explanation: In JavaScript, the "typeof" operator is used for knowing the data type of the specified operand that can be a data structure or literal like an object, method, and variable.


89) For which purpose the array "map()" methods is used ?

  1. It used for mapping the elements of another array into itself.
  2. It passes each data-item of the array and returns the necessary mapped elements.
  3. It passes the data-items of an array into another array.
  4. It passes every element of the array on which it is invoked to the function you specify, and returns an array containing the values returned by that function.

Answer: D

Explanation: The "map()" method is one of the built-in methods of the JavaScript that is used for mapping the data-items of the array, which can be used later for some other purpose. It passes every element of the array on which it is invoked to the function we specify, and returns an array containing the values returned by that function.


90) Both the "rduucedRight()" and "reduce()" methods follow which one of the following common operation?

  1. inject and fold
  2. filter and fold
  3. finger and fold
  4. fold

Answer: A

Explanation: In JavaScript, the reduce() method reduces the size of the array to a single value. This method executes a provided specific method on each data-item or element of the array in the left to right manner. It stored the value returned by the function in an accumulator. However, it does not execute the provided function on the array's elements, which has no value.

The "reduceRigth()" method does the same work of reducing the array to a single individual value and calls or executes a certain function on each element of the array but in the right to left manner. It also stores the value returned by the function in an accumulator, such as total or result.

So as we can see that both the methods "reduce()" and "reduceRight()" almost do the same work that is known as inject and fold.


91) Which one of the following given task is performed by the "pop()" method of the array?

  1. Itupdates the element of the array
  2. it increments the total length of the array by 1
  3. It prints the first element and made no impact on the length of the array
  4. updates the element removes one element of an array on each time the "pop()" function called

Answer: D

Explanation: The "pop()" method is used for removing the last element of the array, or we can say, it removes/deletes the element from the tail-side of an array. Hence every time the "pop()" method is called, the value of the array's length gets decremented by one.


92) What will happen if we use the "join()" method along with the "reverse()" method?

  1. It will reverse and concatenates the elements of the array
  2. It will reverse the element and store the elements in the same array
  3. It will just reverse the element of the array
  4. It will store the elements of the specified array in the normal order

Answer: B

Explanation: The "array.join()" method is one of the predefined methods of the JavaScript. It is used for joining the data-items of an array and converts them into a string. The "Reverse()" method, which is used along with it, reverses the specified array, and it stores the array into the memory once it gets reversed.


93) What will be the output of the following given code of JavaScript?

  1. true true
  2. false true
  3. true false
  4. false true

Answer: C

Explanation: As we can see in the given code, the "x1" array is defined but with the null values by which we can easily access the index 0,1,2 of it. We can access the largest index of the array in which any value or even null value is defined. In the "x2" array, we cannot access the index 0 because the "x2" array is declared, but it is not defined till now.


94) What will happen if we execute the following piece of code?

  1. The output will be 4 3 1
  2. The output will be 4 3 undefined 1
  3. It will result in an error
  4. It does not run at all

Answer: B

Explanation: In JavaScript, if user defines an array and does not define value of any element, there will be no error. But if user tries to print the element of the array whose value is not defined, it will print the "undefined" as the value of that element.


95) What output we may get if we execute the following JavaScript code:

  1. 0124
  2. 01234
  3. It will throw a error
  4. No output

Answer: A

Explanation: In the above-given code, the "continue" keyword mentioned which is commonly used in loops for skipping the specific iteration of a loop and jumping to the next iteration of the loop without exiting the loop's body. As you can see in the above code when the value of variable "i" gets equal to the 3, the "continue" keyword executed and control skips current iteration and jump to the next iteration.


96) What will be the output of the following JavaScript code?

  1. 1, 2, 3
  2. Error
  3. It will concatenate both the stings and print as 1, 2, 3, 4, 5, 6, 7, 8, 9 ,10
  4. It will print nothing

Answer: C

Explanation: In JavaScript, the "concat()" is a predefined method which is used to join the values of two arrays. Both the arrays can contain string or the integers.

Example

Output

Which one of the following options is the correct output for the given code of javascript

VII. This set of questions focuses on the functions and functional programming in JavaScript

97) What is the primary role of the "return ()" statement in a function body?

  1. It returns the value and continues executing rest of the statements
  2. It returns the value and stops the program execution
  3. Stops executing the function and returns the value
  4. It returns the value and stops executing the function

Answer: D

Explanation: In general, the "return" statement is the last statement in the body of function if the function is return-type. Whenever the return statement gets encountered in the definition of the function, the execution of the function will stop, and it returns the stored value to the statement where the function call has been made.


98) If a function which does not return a value is known as _____

  1. Static function
  2. Procedures
  3. Method
  4. Dynamic function

Answer: B

Explanation: Functions that do not return any value are known as void functions and are sometimes called processes.


99) The execution of a function stops when the program control encounters the _________ statement in the body of the function.

  1. return statement
  2. continue statement
  3. break statement
  4. goto statement

Answer: A

Explanation: Whenever a "return" statement is encountered by the program control inside the function's definition, it stops the execution of that function. Statements such as "break" and "continue" are commonly used in the definition of a loop to jump out of the loop (or to skip the rest statements inside the definition of the loop)


100) In which events/scenarios, A function name gets optional in JavaScript?

  1. When a function is defined as a looping statement
  2. When the function is called
  3. When a function is defined as expressions
  4. When the function is predefined

Answer: C

Explanation: A function name becomes optional when it is defined as an "Expression". For Example

Program

var s = function (a, b) {return a * b};

After a function has been stored in a variable, we can use that variable as a function

var s = function (a, b) {return a * b};
var t = s(4, 3);


101) In JavaScript, the definition of a function starts with____

  1. With the Return type, Function keyword, Identifier and Parentheses
  2. With the Identifier and Parentheses
  3. With the Return type and Identifier
  4. With the Identifier and Return type

Answer: A

Explanation: The definition of any function always begins with a "keyword" function, followed by an identifier which is the name of the function as well as with a pair of parentheses that cover the list of identifiers. If the list of identifiers includes more than one identifier, they are separated by commas.


102) What happens if the return statement has no related expression?

  1. It will return a undefined value
  2. It will throw a exception
  3. It will return the 0 as the value
  4. It will throw a error

Answer: A

Explanation: Suppose a function that does not have a return statement in its definition returns a default value. Although the return statement is mentioned in the definition, but not associated with the expression, then it will return the value known as "undefined."


103) Which one of the following options is the correct output for the given code of JavaScript?

  1. Prints the contents of each property of o
  2. Prints the address of elements
  3. Prints only one property
  4. Returns undefined

Answer: D

Explanation: The output of the above JavaScript code will be undefined.


104) Which one of the following code is equivalent to call a function "x" of the class "a" which have two arguments g and h?

  1. a,x(g,h);
  2. x(g) &&a.x(g);
  3. x(a,g);
  4. (g,h);

Answer: A

Explanation: If a function has more than one argument, it is separated by commas. The above code is an invoked expression: in which a function a.x and two arguments "g" and "h" are separated by commas.


105) Which one of the following code is equivalent to the following given code?

  1. x (g) &&a.x (h);
  2. a [ "x" ] ( g , h );
  3. a (x )[ "g" , "h" ];
  4. x( g&&h );

Answer: B

Explanation: We can use the alternate code to perform the same task of accessing the properties of the object and the parenthesis will access the function "x" mentioned in it.


106) Which one of the following options is the correct output for the given code of JavaScript?

  1. 2
  2. 3
  3. 0
  4. Error

Answer: A

Explanation: In JavaScript, document.write () is a predefined method which is used for printing output to the console. Here another function in the document.write () method is passed as an argument that returns the multiplication of variables a and b.


107) Which one of the following options is the correct output for the given code of JavaScript?

  1. 7
  2. 11
  3. 3
  4. 9

Answer: B

Explanation: The "apply()" used in the above given code is a pre-defined method in which an array is passed as an argument and another argument passed a NULL. Here this method searches for the largest integer in the whole array.


108) Which one of the following options is the correct output for the given code of JavaScript?

  1. James
  2. compilation error
  3. runtime error
  4. undefined

Answer: A

Explanation: The "bind()" function mentioned in the above-given code, is used for creating a new function which contains its own set of keywords by default.


109) Which one of the following options is the correct output for the given code of JavaScript?

  1. James Deo
  2. compilation error
  3. runtime error
  4. undefined

Answer: A

Explanation: The "call()" method mentioned in the above given piece of code, is used of calling a function in which the "this" is passed as an argument. It returns the output given by the calling function.


110) Which one of the following options is the correct output for the given code of JavaScript?

  1. 8
  2. 3
  3. 6
  4. Error

Answer: A

Explanation: The "pow()" method used in the above code is one of the built-in methods which are available in the math's library of the JavaScript . This methodaccepts two arguments in which the power of the first argument is calculated with respect to the other argument.


111) Which one of the following keywords is used for defining the function in the JavaScript?

  1. Void
  2. init
  3. main
  4. function

Answer: D

Explanation: In JavaScript, a function is defined by using the "function" keyword along which function is named, followed by the () parenthesis. A function name can contain the dollar's signs, underscores, letters and even the digits.


112) In JavaScript, do the functions always return a value?

  1. Yes, functions always returns a value
  2. No, it is not necessary
  3. A number of functions return values by default
  4. some functions do not return any value

Answer: C

Explanation: In JavaScript, a number of functions that contain a return statement usually return a value. The functions which does not have the return statement in their definition does not return any value but few of them also return value by default even if they do not contain a return statement.


113) Which one of the following codes is correct for concatenating the strings passed into the function?

A. Code 1

B. Code 2

C. Code 3

D. Code 4


Answer: B

Explanation: The "concat()" method is a predefined method of the JavaScript which is used for joining the two or more arrays. The significant advantage of using this method is instead of making changes in the existing array it returns a newly created array. The ".apply" method is also predefined method just like the" concat()", and it takes arrays of arguments and consider the every element of that array as an individual argument.


114) Which of the following values will be returned by the last statement in the given code?

  1. 10
  2. 12
  3. 8
  4. 9

Answer: C

Explanation: The code given in the following question creates at least 10 closures, stores them as an array.Closures are all specified within the same function invocation, so they share access to the variable i.At the time of "constfun()" method returns 10 as the value of the variable i, all closures shares this value. So, all functions in a given array of functions return the exact same value.


115) What will be the correct output of the following JavaScript code?

  1. 1.01
  2. 1.10
  3. 1.05
  4. 1.11

Answer: B

Explanation: The "atan2()" method used in the given code returns the arctangent of the quotient of its arguments, as the numeric values between -PI and PI radians. The returned digit represents the counterclockwise angle in radians (instead of degrees) between the positive X-axis and the point (x,y).


116) What will be the correct output of the following JavaScript code?

  1. 0.80
  2. 0.78
  3. 0.50
  4. 0.88

Answer: D

Explanation: The "asinh()" method used in the given code is a predefined method available in the math's library of the JavaScript which returns the hyperbolic arcsine of a number.


117) What will happen if we execute the following code of JavaScript?

  1. Memory leak
  2. Error
  3. Exception will be thrown
  4. Yes, perfectly

Answer: D

Explanation: The function name is optional for functions defined as expressions. Function expressions are sometimes defined and implemented immediately.


118) What output will come if we run the following part of the JavaScript code?

  1. Exception
  2. 123abc
  3. 123
  4. NaN

Answer: C

Explanation: The "parseIn()" is a pre-defined method of the JavaScript that parses a string, and as a result, it returns an integer. It also returns the first digit as 0 if the string does not contain an integer in the first place.


119) Which one of the given options can be considered as a code equivalent to the following code?

  1. var o= new Object;
  2. var o;
  3. var o = Object();
  4. Object o=new Object();

Answer: C

Explanation: In JavaScript, as the only particular case of the "new" operator, the grammar is simplified by JavaScript by allowing the parentheses to be removed when there are no arguments passed in the function calling. So, user can neglect the empty pair of parentheses in every case of constructor invocation, in which there are no arguments.


120) If the following lines of code differ, what is the difference?

Code A

Code B

  1. The first line results in a realBoolean value whereas the second line merely checks for the existence of the objects
  2. Both the lines of code A and B will result in a Boolean value "False"
  3. Both the lines of code A and B will check just for the existence of the object alone
  4. Both the lines of code A and B will result in a Boolean value "True"

Answer: A

Explanation: Code A will return output in the form of a "real" boolean value because we first do what is written inside the parentheses, but then negate it again immediately. Therefore, it is saying something that is not true, makes it true.

Code B looks for the existence of the obj1 and obj2. Also, it may not necessarily return a "real" boolean value. This means instead of returning either true or false and it can be problematic because false-y can be either an empty string or can be 0.


121) In the following code, what value should the variable "a" contain?

  1. Null
  2. 0
  3. 2
  4. Undefined

Answer: C

Explanation: The "counter()" method used in the above code made increment in the value of the variable by one each time it is called, and the" reset()" function resets the value of that variable to zero. Therefore if we look carefully, we can see that on variable "y" the "counter()" method was called two times, and the "reset()" method was not called even for one time, so the value of the variable y will be 2.


122) Which one of the given options can be considered as the correct output of the following code?

  1. 12
  2. 13
  3. 15
  4. Error

Answer: C

Explanation: The "addition()" function was defined in the first line of code using the "new" property. In the second line of code, the addition function is called along with two passed arguments as 10, 5 inside the "document.write()" method, which prints the sum of two passed arguments returned by the "addition()" method.


VIII. This set of questions focuses on the Closures in JavaScript:

123) Which one of the following is not a example of closures?

  1. Graphics
  2. Variables
  3. Functions
  4. Objects

Answer: A

Explanation: A closure is created each time a function is created in JavaScript. In general, we can say that all the closures are function or vice versa, and function has a scope chain associated with them.


124) What output will be returned by the function in the following code?

  1. It will returns the value in scope
  2. It will returns value null
  3. It will returns an exception
  4. It will show an error message

Answer: A

Explanation: Each block of code, function, or script as a whole always has an object, associated with them, called a Lexical environment. Therefore, the JavaScript code given in the above question will return the value in scope.


125) What is the primary rule of the Lexical Scoping?

  1. Functions are always declared in the scope
  2. Variables are declared inside the function
  3. Functions are always declared outside the scope
  4. Functions gets executes using scope chain

Answer: D

Explanation: The fundamental rule of lexical scoping is that: In the JavaScript, A function gets executed using the scope chain which was in effect, when they are defined.


126) What is required in order to implement the Lexical Scoping?

  1. To reference the current scope chain
  2. Dereference the current scope chain
  3. Get the object
  4. Return the value

Answer: A

Explanation: It is necessary to include not only that function's code in the internal state of the function's object, but also to provide references to the current scope chain.


127) Which one of the following utilize the CPU cycles in a massive manner?

  1. GUI (Graphic User Interface)
  2. Statically generated graphics
  3. Generic scoping
  4. Dynamically generated graphics

Answer: D

Explanation: The term "Dynamic generated graphic" refers to simulate movement, motion, or generating a specific environment using the computer. It can also be thought of as multiple plots associated with time. Hence the graphics generated in the dynamic manner from the real time data utilize the huge part of the CPU cycles.


128) In JavaScript, what kind of scoping is used?

  1. Literal scoping
  2. Sequential scoping
  3. Segmental scoping
  4. Lexical scoping

Answer: D

Explanation: In JavaScript, the lexical scoping is used just like many other modern languages.This means a function gets executed using the scope chain which was in effect, when they are defined instead of variable scope which was in effect when they are invoked/called.


129) What are the closures?

  1. Both Function objects and Scope where function's variables are resolved
  2. Scope where function's variables are resolved
  3. Function objects
  4. Function return value

Answer: C

Explanation: A closure can be referred as the set of a function's object and a scope (a group of variable bindings) in which the variables of that functions are resolved is known as the closure.


130) Which one of the following can be considered as the opposite approach of the Lexical Scoping?

  1. Dynamic scoping
  2. Literal scoping
  3. Static scoping
  4. Generic scoping

Answer: A

Explanation: The dynamic scoping can be considered as the opposite approach to the lexical scoping. In the dynamic scoping, it does not matter that how the code is written but what matters is how's the code executes. At the time of execution of every new function, a new scope associated with it gets pushed onto the stack and this scope normally stored along with the function call stack.At that point, when a variable is referenced in a function's definition, the scope is immediately checked in every call stack to know if it returns a value.


131) Which one of the following algorithmic languages is not the lexical scoping standardized in?

  1. Html
  2. Ada
  3. Pascal
  4. Modula2

Answer: A

Explanation: The Lexical scoping is Standardized in all following given algorithmic languages except the HTML.


132) What will be the output of the following JavaScript code?

  1. False
  2. 1
  3. 0
  4. True

Answer: D

Explanation: A "constructor " is a function property of any class that is typically used for object of that class . In the above given code, both 1,2 statements are creating the instance of the class.


133) Which one of the given options can be considered as the correct output for the following JavaScript code?

  1. Undefined
  2. 18,1
  3. 7,1
  4. Error

Answer: C

Explanation: The "object.assign()" method mentioned in the above code, is used for copying the values and properties of one object to another. Here the objects are assigned and will be copied by the reference.


134) Which of the following POSIX signals generate events?

  1. SIGINT
  2. SIGDOWN
  3. SIGFLOAT
  4. SIGSHORT

Answer: A: "SIGINT" is the correct answer.


135) Which HTML element is used to put the JavaScript code?