Sail E0 Webinar

MCQs

Total Questions : 10
Question 1. Which are usually variables that are used internally in object methods and also are globally visible variables?
  1.    Object properties
  2.    Variable properties
  3.    Method properties
  4.    Internal properties
 Discuss Question
Answer: Option B. -> Variable properties


The variable properties are usually variables that are used internally in the objects methods, but can also be globally visible variables that are used through the page.


Question 2. Why was "The Good Parts designed as a language subset in JavaScript?
  1.    To improve programmer flexibility
  2.    To balance the work load of the programmer
  3.    To create an in-built compiler and interpreter
  4.    To improve programmer productivity
 Discuss Question
Answer: Option D. -> To improve programmer productivity


The Good Parts is a language subset designed for aesthetic reasons and with a desire to improve programmer productivity. There is a larger class of subsets that have been designed for the purpose of safely running untrusted JavaScript in a secure container or "sandbox.


Question 3. When a class B can extend another class A, we say that
  1.    A is the superclass and B is the subclass
  2.    B is the superclass and A is the subclass
  3.    Both A and B are the superclass
  4.    Both A and B are the subclass
 Discuss Question
Answer: Option A. -> A is the superclass and B is the subclass


Instances of B inherit all the instance methods of A. The class B can define its own instance methods, some of which may override methods of the same name defined by class A.


Question 4. The basic difference between JavaScript and Java is
  1.    There is no difference
  2.    Functions are considered as fields
  3.    Variables are specific
  4.    functions are values, and there is no hard distinction between methods and fields
 Discuss Question
Answer: Option D. -> functions are values, and there is no hard distinction between methods and fields


The basic difference between JavaScript and Java is that the functions are values, and there is no hard distinction between methods and fields.


Question 5. Consider the following code snippetconsole.log(p)If p is not defined, what would be the result or type of error?
  1.    Zero
  2.    Null
  3.    ReferenceError
  4.    ValueNotFoundError
 Discuss Question
Answer: Option C. -> ReferenceError


In the above code snippet, p is not defined. Hence, it gives a ReferenceError.


Question 6. Which are the two functions that are not allowed in any secure subset?
  1.    evaluate() and restrict()
  2.    eval() and the Function() constructor
  3.    debugger() and test()
  4.    eval() and debugger()
 Discuss Question
Answer: Option B. -> eval() and the Function() constructor


eval() and the Function() constructor are not allowed in any secure subset because they allow the execution of arbitrary strings of code, and these strings cannot be statically analyzed.


Question 7. What will be the reaction when a catch clause has no conditionals ?
  1.    Takes it to be 0
  2.    Takes it to be 1
  3.    Takes it to be true
  4.    Takes it to be false
 Discuss Question
Answer: Option C. -> Takes it to be true


If a catch clause has no conditional, it behaves as if it has the conditional if true, and it is always triggered if no clause before it was triggered.


Question 8. What does the subexpression /java(script)?/ result in ?
  1.    It matches java" followed by the optional script"
  2.    It matches java" followed by any number of script"
  3.    It matches java" followed by a minimum of one script"
  4.    None of the mentioned
 Discuss Question
Answer: Option D. -> None of the mentioned


The subexpression /java(script)?/ matches "java followed by the optional "script.


Question 9. To define each of the set classes as a property of the sets object (namespace) for the module, the statement is
  1.    sets = sets.AbstractEnumerableSet.extend();
  2.    sets.SingletonSet = sets.AbstractEnumerableSet.extend(...);
  3.    sets.SingletonSet = sets.extend(...);
  4.    sets = sets.extend(...);
 Discuss Question
Answer: Option B. -> sets.SingletonSet = sets.AbstractEnumerableSet.extend(...);


The sets object is the namespace for the module, and we define each of the set classes as a property of this object.


Question 10. Consider the following statement containing regular expressionsvar text = "testing: 1, 2, 3"; var pattern = /\d+/g;In order to check if the pattern matches, the statement is
  1.    text==pattern
  2.    text.equals(pattern)
  3.    text.equals(pattern)
  4.    pattern.test(text)
 Discuss Question
Answer: Option D. -> pattern.test(text)


The given pattern is applied on the text given in the paranthesis.


Latest Videos

Latest Test Papers