Q 1. Which of the following variables takes precedence over the others if the names are the same?
A. Global variable
B. The two of the above
C. The local element
D. None of the above
Show Answer
Answer:-C. The local elementExplanation
In JavaScript, the local variable takes precedence over the global variable if the name of both local and global variables is the same.Q 2. Which one of the following is the correct way for calling the JavaScript code?
A. Pre-processors
B. Triggering Event
C. RMI
D. Function/Method
Show Answer
Answer:-D. Function/MethodExplanation
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.Q 3. Which of the following type of a variable is volatile?
A. Volatile variable
B. Dynamic variable
C. Mutable variable
D. Immutable variable
Show Answer
Answer:-C. Mutable variableExplanation
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.Q 4. Which of the following option is used as hexadecimal literal beginning?
A. 00
B. 0x
C. 0X
D. Both 0x and 0X
Show Answer
Answer:-D. Both 0x and 0XExplanation
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.Q 5. When there is an indefinite or an infinite value during an arithmetic computation in a program, then JavaScript prints______.
A. Prints an exception error
B. Displays “Infinity”
C. Prints an overflow error
D. Prints the value as such
Show Answer
Answer:-B. Displays “Infinity”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.Q 6. In the JavaScript, which one of the following is not considered as an error:
A. Syntax error
B. Missing of semicolons
C. Missing of Bracket
D. Division by zero
Show Answer
Answer:-D. Division by zeroExplanation
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.Q 7. Which of the following given functions of the Number Object formats a number with a different number of digits to the right of the decimal?
A. toExponential()
B. toFixed()
C. toPrecision()
D. toLocaleString()
Show Answer
Answer:-B. toFixed()Explanation
The “tofixed()” method formats the given number with a specific number of digits to the right of the decimal.Q 8. Which of the following number object function returns the value of the number?
A. valueOf()
B. toString()
C. toLocaleString()
D. toPrecision()
Show Answer
Answer:-A. valueOf()Explanation
The method ” valueOf()” returns the value of the parameter that was passed in it.Q 9. 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?
A. slice()
B. split()
C. substr()
D. search()
Show Answer
Answer:-C. substr()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.Q 10. In JavaScript the x===y statement implies that:
A. Both x and y are equal in value, type and reference address as well.
B. Both are x and y are equal in value only.
C. Both are equal in the value and data type.
D. Both are not same at all.
Show Answer
Answer:-C. Both are equal in the value and data type.Explanation
The “===” statement are called strict comparison which only gets true only if the type and content of both the operand are strictly same. ProgramThe concept of the “===” stement
Output True FalseQ 11. Choose the correct snippet from the following to check if the variable “a” is not equal the “NULL”:
A. if (a!)
B. if(a!==null)
C. if(a!null)
D. if(a!=null)
Show Answer
Answer:-B. if(a!==null)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.Q 12. 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:
A. toString()
B. String(human)
C. String newvariable=”human”
D. Both human.toString() and String(human)
Show Answer
Answer:-D. Both human.toString() and String(human)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).Q 13. See the given code of JavaScript and choose the correct output from the following:
functioncomparing()
{
intx=9;
chary=9;
if(x==y)
returntrue;
else
returnfalse;
}
A. compilation error
B. false
C. runtime error
D. true
Show Answer
Answer:-D. trueExplanation
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.Q 14. What will be the output of the following JavaScript code
functioncomparison()
{
int number=10;
if(number===”10″)
returntrue;
else
returnfalse;
}
A. True
B. false
C. runtime error
D. compilation error
Show Answer
Answer:-A. TrueExplanation
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.Q 15. Find out the correct output of the following given piece of code from the given options:
functionfun()
{
int y=10;
char z=10;
if(y.tostring()===z)
returntrue;
else
returnfalse;
}
A. logical error
B. false
C. runtime error
D. true
Leave a Reply