Q. Modules that have more than one item in their API can

  • (A) Assign itself to a global variable
  • (B) Invoke another module of the same kind
  • (C) Return a namespace object
  • (D) Invoke another module of the same kind
πŸ’¬ Discuss
βœ… Correct Answer: (C) Return a namespace object
Explanation: Modules that have more than one item in their API can return a namespace object.

Q. The provides() function and the exportsobject are used to

  • (A) Register the module’s API and Store their API
  • (B) Store the module’s API and register their API
  • (C) Store the module’s API
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) Register the module’s API and Store their API
Explanation: Frameworks that define module loading systems may have other methods of exporting a module’s API. There may be a provides() function for modules to register their API, or an exports object into which modules must store their API.

Q. Consider the following code snippet
var sets = com.davidflanagan.collections.sets;
What is the programmer trying to do in the above code snippet?

  • (A) Importing a single module
  • (B) Importing a module partially
  • (C) Importing a namespace
  • (D) Importing the entire module
πŸ’¬ Discuss
βœ… Correct Answer: (D) Importing the entire module
Explanation: Rather than importing individual classes, a programmer might import the entire module to the global namespace.

Q. The properties() method is a

  • (A) Enumerable method
  • (B) Non-enumerable method
  • (C) Operational method
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (B) Non-enumerable method
Explanation: The properties() method is a non-enumerable method.

Q. What can be done in order to avoid creation of global variables in JavaScript?

  • (A) To use a method that defines all the variables
  • (B) To use an object that has the reference to all the variables
  • (C) To use an object as its namespace
  • (D) To use global functions
πŸ’¬ Discuss
βœ… Correct Answer: (C) To use an object as its namespace
Explanation: One way for a module to avoid the creation of global variables is to use an object as its namespace. Instead of defining global functions and variables, it stores the functions and values as properties of an object (which may be referenced to a global variable).

Q. The ‘$’ present in the RegExp object is called a

  • (A) character
  • (B) matcher
  • (C) metacharacter
  • (D) metadata
πŸ’¬ Discuss
βœ… Correct Answer: (C) metacharacter
Explanation: The ‘S’ is a special metacharacter that matches the end of a string.

Q. The four kinds of class members are

  • (A) Instance methods, Instance fields, Static method, Dynamic method
  • (B) Instance fields, Instance methods, Class fields, Class methods
  • (C) Instance fields, Non-instance fields, Dynamic methods, Global methods
  • (D) Global methods, Local methods, Dynamic methods, Static methods
πŸ’¬ Discuss
βœ… Correct Answer: (B) Instance fields, Instance methods, Class fields, Class methods
Explanation: The four kinds of class members are Instance fields, Instance methods, Class fields, Class methods.

Q. The properties of the objects act like different kinds of class members. They are

  • (A) Public object, Private object, Protected object
  • (B) Constructor object, Function object, Destructor object
  • (C) Constructor object, Prototype object, Instance object
  • (D) Instance method, Static object, Dynamic object
πŸ’¬ Discuss
βœ… Correct Answer: (C) Constructor object, Prototype object, Instance object
Explanation: In JavaScript, there are three different objects involved inany class definition, and the properties of these three objects act like different kinds of class members namely, Constructor object, Prototype object, and Instance object.

Q. The object whose properties are inherited by all instances of the class, and properties whose values are functions behaving like instance methods of the class, is

  • (A) Instance object
  • (B) Constructor object
  • (C) Destructor object
  • (D) Prototype object
πŸ’¬ Discuss
βœ… Correct Answer: (D) Prototype object
Explanation: The properties of the prototype object are inhertied by all instances of the class, and properties whose values are functions behave like instance methods of the class.

Q. Which are usually variables that are used internally in object methods and also are globally visible variables?

  • (A) Object properties
  • (B) Variable properties
  • (C) Method properties
  • (D) Internal properties
πŸ’¬ Discuss
βœ… Correct Answer: (B) Variable properties
Explanation: 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.