InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which of the following is an example to perform the most common XML manipulations using the XML objects invocation?(a) insertChildBefore()(b) insertChildAfter()(c) appendChildAfter(…)(d) appendChildBefore(…)I got this question during an internship interview.This intriguing question comes from Shorthand functions and Multiple catch clauses in section Classes and Modules in JavaScript of JavaScript |
|
Answer» RIGHT CHOICE is (a) insertChildBefore() EASIEST EXPLANATION: E4X is designed so that you can perform most common XML manipulations using language syntax. E4X also defines methods you can invoke on XML OBJECTS. Here, for example, is the insertChildBefore() method: |
|
| 2. |
Which method to use while working with XML fragments, instead of XML()?(a) XMLInterface()(b) XMLClass()(c) XMLList()(d) XMLArray()I got this question at a job interview.My doubt is from Shorthand functions and Multiple catch clauses in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct answer is (C) XMLLIST() |
|
| 3. |
Which of the following is the descendant operator?(a) ..(b) …(c) *(d) @I had been asked this question in an online quiz.I'm obligated to ask this question of Shorthand functions and Multiple catch clauses in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct option is (a) .. |
|
| 4. |
When will the finally block be called?(a) When there is no exception(b) When the catch does not match(c) When there is exception(d) After try-catch executionI have been asked this question in an interview.Asked question is from Shorthand functions and Multiple catch clauses topic in section Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct answer is (d) After try-catch execution |
|
| 5. |
What will be the reaction when a catch clause has no conditionals?(a) Takes it to be 0(b) Takes it to be 1(c) Takes it to be true(d) Takes it to be falseThe question was asked by my school teacher while I was bunking the class.My question is based upon Shorthand functions and Multiple catch clauses in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct option is (C) Takes it to be TRUE |
|
| 6. |
What is the return type of typeof for standard JavaScript objects?(a) xml(b) object(c) dom(d) htmlI got this question during an interview.Question is taken from Shorthand functions and Multiple catch clauses topic in section Classes and Modules in JavaScript of JavaScript |
|
Answer» Right option is (b) object |
|
| 7. |
Which exception does the Iterators throw from their next() method when there are no more values to iterate, that work on finite collections?(a) Exit Iteration(b) Abort Iteration(c) Abort(d) Stop IterationThe question was posed to me during an internship interview.This interesting question is from JavaScript Extensions in section Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct answer is (d) Stop ITERATION |
|
| 8. |
What is the code to be used to trim whitespaces?(a) let trimmed = (l.trim() for (l in lines));(b) let trimmed = (trim(l));(c) let trimmed = l.trim();(d) let trimmed = for(l in lines));This question was addressed to me in an interview for job.Query is from Shorthand functions and Multiple catch clauses topic in section Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct OPTION is (a) let trimmed = (l.TRIM() for (l in lines)); |
|
| 9. |
Which looping statement allows XML tags to appear in JavaScript programs and adds API for operating on XML data?(a) for loop(b) while loop(c) for/each loop(d) do while loopThis question was posed to me in an international level competition.My query is from JavaScript Extensions topic in section Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct answer is (c) for/each loop |
|
| 10. |
The main difference between the variables declared with var and with let is __________(a) var is confined to a particular function but let is not(b) let is confined to a particular function but var is not(c) var defines values based on conditions but let does not(d) let doesn’t let you change the value of the variableI had been asked this question in my homework.My query is from JavaScript Extensions topic in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» Right choice is (b) let is CONFINED to a particular function but var is not |
|
| 11. |
The let keyword cannot be used ___________(a) as a substitute of var(b) as a block statement to define new variables(c) to define variables that are scoped to a single expression(d) in a else if loop, as a substitute for varI have been asked this question in an interview for job.My enquiry is from JavaScript Extensions topic in division Classes and Modules in JavaScript of JavaScript |
|
Answer» Right option is (d) in a else if LOOP, as a substitute for var |
|
| 12. |
Which was one of the first security subsets proposed?(a) FBJS(b) Caja(c) dojox.secure(d) ADSafeThis question was addressed to me in my homework.My question is taken from JavaScript Subsets topic in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct option is (d) ADSafe |
|
| 13. |
Which is the object that defines methods that allow complete control over page content?(a) The client-side document object(b) The server-side document object(c) Both client-side and server-side document object(d) Web document objectThis question was posed to me during an online exam.The question is from JavaScript Subsets in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» RIGHT choice is (a) The client-side document OBJECT Explanation: A web page is divided into two object documents in which ONE is client-side document object and the other is server-side document object. The client-side document object defines methods that allow COMPLETE control over page content |
|
| 14. |
Which are the two functions that are not allowed in any secure subset?(a) evaluate() and restrict()(b) eval() and the Function() constructor(c) debugger() and test()(d) eval() and debugger()I had been asked this question in homework.Question is taken from JavaScript Subsets in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» Right answer is (b) eval() and the FUNCTION() constructor |
|
| 15. |
Why was “The Good Parts” designed as a language subset in JavaScript?(a) To improve programmer flexibility(b) To balance the workload of the programmer(c) To create an in-built compiler and interpreter(d) To improve programmer productivityI got this question in examination.My enquiry is from JavaScript Subsets in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct CHOICE is (d) To improve programmer productivity |
|
| 16. |
Why is this keyword not preferred in JavaScript?(a) Highly memory consuming(b) Functions should access the global objects(c) Functions should not access the global objects(d) Very inefficient to useThis question was posed to me in quiz.I need to ask this question from JavaScript Subsets in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» CORRECT answer is (c) FUNCTIONS should not access the global objects For explanation I WOULD say: The this keyword is forbidden or RESTRICTED because functions (in non-strict mode) can access the global object through this. Preventing access to the global object is ONE of the key purposes of any sandboxing system. |
|
| 17. |
Which is the subset that is a secure container designed for the purpose of safely running untrusted JavaScript?(a) Sandbox(b) The Good Parts(c) Both Sandbox and Good Parts(d) Web browserThe question was asked during an interview for a job.My question is from JavaScript Subsets topic in division Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct choice is (a) SANDBOX |
|
| 18. |
What is being imposed on each subset to ensure that it conforms to the subset?(a) A parser to parse the code(b) A parser that parses and adds to the subset(c) A static verifier that parses code(d) A predefined function to parse the codeThe question was posed to me at a job interview.Origin of the question is JavaScript Subsets in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» Right OPTION is (c) A static verifier that parses code |
|
| 19. |
What does javascript use instead of == and !=?(a) It uses bitwise checking(b) It uses === and !== instead(c) It uses equals() and notequals() instead(d) It uses equalto()The question was posed to me during an interview for a job.This intriguing question comes from JavaScript Subsets topic in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» RIGHT ANSWER is (b) It uses === and !== instead Best EXPLANATION: The subset does not include the comma operator, the bitwise operators, or the ++ and — operators. It also disallows == and != because of the TYPE conversion they perform, requiring USE of === and !== instead. |
|
| 20. |
The Crockford’s subset does not include which function in JavaScript?(a) eval()(b) coeval()(c) equal()(d) equivalent()I had been asked this question during an interview.My doubt stems from JavaScript Subsets in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» CORRECT OPTION is (a) eval() EXPLANATION: The Crockford’s subset does not INCLUDE the with and continue statements or the eval() FUNCTION. It defines functions using function definition expressions only and does not include the function definition statement. |
|
| 21. |
The method that performs the search-and-replace operation to strings for pattern matching is _______(a) searchandreplace()(b) add()(c) edit()(d) replace()This question was addressed to me during an internship interview.My doubt is from Pattern Matching and Regular Expressions topic in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct CHOICE is (d) replace() |
|
| 22. |
What is the most essential purpose of parentheses in regular expressions?(a) Define pattern matching techniques(b) Define subpatterns within the complete pattern(c) Define portion of strings in the regular expression(d) matching the complete stringThis question was addressed to me during an interview.I want to ask this question from Pattern Matching and Regular Expressions topic in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct option is (b) Define subpatterns within the COMPLETE pattern |
|
| 23. |
What does the subexpression /java(script)?/ result in?(a) It matches “java” followed by the optional “script”(b) It matches “java” followed by any number of “script”(c) It matches “java” followed by a minimum of one “script”(d) It matches “java” followed by a single “script”I have been asked this question during an online exam.This interesting question is from Pattern Matching and Regular Expressions topic in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» Right CHOICE is (a) It matches “java” followed by the optional “SCRIPT” |
|
| 24. |
What will be the result when non greedy repetition is used on the pattern /a+?b/?(a) Matches the letter b preceded by the fewest number of a’s possible(b) Matches the letter b preceded by any number of a(c) Matches letter a preceded by letter b, in the stack order(d) Matches letter a present in the stringI got this question in an interview.The question is from Pattern Matching and Regular Expressions in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct option is (a) Matches the LETTER b preceded by the fewest number of a’s possible |
|
| 25. |
What does /[^(]* regular expression indicate?(a) Match one or more characters that are not open parenthesis(b) Match zero or more characters that are open parenthesis(c) Match zero or more characters that are not open parenthesis(d) Match one or more characters that are open parenthesisThis question was addressed to me in final exam.This intriguing question comes from Pattern Matching and Regular Expressions in division Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct choice is (c) Match zero or more characters that are not OPEN parenthesis |
|
| 26. |
The regular expression to match any one character not between the brackets is __________(a) […](b) [^](c) [^…](d) [\D]This question was addressed to me during an online interview.This interesting question is from Pattern Matching and Regular Expressions topic in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct ANSWER is (C) [^…] |
|
| 27. |
The provides() function and the exportsobject are used to _________(a) Register the module’s API and Store their API(b) Call the modules api(c) Store the module’s API(d) Register the modules apiThe question was asked by my school principal while I was bunking the class.My question is from Modules in JavaScript topic in division Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct choice is (a) Register the MODULE’s API and Store their API |
|
| 28. |
The ‘$’ present in the RegExp object is called a ____________(a) character(b) matcher(c) metacharacter(d) metadataI had been asked this question by my school teacher while I was bunking the class.I want to ask this question from Pattern Matching and Regular Expressions in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct answer is (C) metacharacter |
|
| 29. |
The properties() method is a ________(a) Enumerable method(b) Non-enumerable method(c) Operational method(d) calling methodThe question was asked in my homework.The question is from Modules in JavaScript in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct answer is (b) Non-enumerable method |
|
| 30. |
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 kindThis question was addressed to me by my college director while I was bunking the class.Origin of the question is Modules in JavaScript in division Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct answer is (c) RETURN a namespace object |
|
| 31. |
The scope of a function is also called as ________(a) Predefined function(b) Module function(c) Public function(d) Private functionThe question was posed to me by my college professor while I was bunking the class.Asked question is from Modules in JavaScript in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct answer is (b) MODULE function |
|
| 32. |
To define each of the set classes as a property of the sets object (namespace) for the module, the statement is(a) sets = sets.AbstractEnumerableSet.extend();(b) sets.SingletonSet = sets.AbstractEnumerableSet.extend(…);(c) sets.SingletonSet = sets.extend(…);(d) sets = sets.extend(…);This question was posed to me during a job interview.The origin of the question is Modules in JavaScript topic in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct answer is (b) sets.SingletonSet = sets.AbstractEnumerableSet.EXTEND(…); |
|
| 33. |
The maximum number of global symbols a module can define is ____________(a) 2(b) 3(c) 1(d) 4This question was posed to me in exam.I'd like to ask this question from Modules in JavaScript in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct OPTION is (C) 1 |
|
| 34. |
What is the procedure to add methods to HTMLElement so that they will be inherited by the objects that represent the HTML tags in the current document?(a) HTMLElement.prototype(…)(b) HTMLElement.prototype(c) HTML.addmethods()(d) HTML.elements(add)The question was posed to me in quiz.My query is from Augmentation of Classes in division Classes and Modules in JavaScript of JavaScript |
|
Answer» The CORRECT answer is (b) HTMLElement.prototype |
|
| 35. |
The functions provide() and require() of Dojo toolkit and Google’s Closure library are used for ___________(a) declaring and loading modules(b) declaring functions(c) declaring modules(d) loading modulesThe question was asked during a job interview.Query is from Modules in JavaScript in division Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct option is (a) declaring and loading modules |
|
| 36. |
How can we make methods available on all objects?(a) Object.add(methods)(b) Object.methods(add)(c) Object.add.methods(…)(d) Object.prototypeI have been asked this question in final exam.The query is from Augmentation of Classes in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» RIGHT choice is (d) Object.prototype Easiest explanation: It is possible to ADD methods to Object.prototype, making them AVAILABLE on all objects. This is not recommended, however, because prior to ECMAScript5, there is no way to make these add-on methods non enumerable, and if you add properties to Object.prototype, those properties will be REPORTED by all for/in LOOPS. |
|
| 37. |
Which is the correct code that returns a complex number that is the complex conjugate of this one?(a) Complex.prototype.conj = function() { return new Complex(this.r, -this.i); };(b) Complex.prototype.conj = function() { return Complex(this.r, -this.i); };(c) Complex.prototype.conj = function() { return (this.r, -this.i); };(d) Complex.prototype.conj = function() { new Complex(this.r, -this.i); };I got this question in exam.My doubt stems from Augmentation of Classes topic in division Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct answer is (a) Complex.prototype.conj = FUNCTION() { RETURN new Complex(this.r, -this.i); }; |
|
| 38. |
The different variant of Date() constructor to create date object is/are ___________i. new Date(date)ii. new Date(milliseconds)iii. new Date(date string)iv. new Date(year, month, date[hour, minute, second, millisecond])(a) i, ii and iii only(b) ii, iii and iv only(c) i, ii and iv only(d) i, ii, iii and ivThe question was posed to me in examination.Question is from Augmentation of Classes in section Classes and Modules in JavaScript of JavaScript |
|
Answer» Right ANSWER is (b) ii, III and iv only |
|
| 39. |
The class that represents the regular expressions is ________(a) RegExpObj(b) RegExpClass(c) RegExp(d) StringExpThe question was asked in an international level competition.My doubt stems from Augmentation of Classes topic in division Classes and Modules in JavaScript of JavaScript |
|
Answer» CORRECT answer is (c) REGEXP The explanation is: REGULAR expression is an object that DESCRIBES a pattern of characters. The JavaScript RegExp class REPRESENTS regular expressions, and both string and RegExp define methods that use regular expressions. |
|
| 40. |
Which variables are used internally in object methods and are also globally visible?(a) Object properties(b) Variable properties(c) Method properties(d) Internal propertiesI have been asked this question in final exam.My query is from Augmentation of Classes topic in section Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct choice is (b) VARIABLE PROPERTIES |
|
| 41. |
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 objectThe question was asked in my homework.My query is from Augmentation of Classes topic in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» RIGHT answer is (d) PROTOTYPE object For explanation: The PROPERTIES of the prototype object are inherited by all instances of the class, and properties whose values are functions behave LIKE instance methods of the class. |
|
| 42. |
Different kinds of the object involved in a class definition 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 objectI got this question in an online interview.Question is taken from Augmentation of Classes topic in section Classes and Modules in JavaScript of JavaScript |
|
Answer» Correct option is (C) Constructor object, Prototype object, INSTANCE object |
|
| 43. |
If A is the superclass and B is the subclass, then subclass inheriting the superclass can be represented as _________(a) B=inherit(A);(b) B=A.inherit();(c) B.prototype=inherit(A);(d) B.prototype=inherit(A.prototype);I got this question during an online interview.My doubt stems from Classes in JavaScript topic in division Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct ANSWER is (c) B.PROTOTYPE=INHERIT(A); |
|
| 44. |
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 methodsThe question was posed to me during an online exam.The question is from Augmentation of Classes in division Classes and Modules in JavaScript of JavaScript |
|
Answer» Right choice is (b) INSTANCE fields, Instance methods, Class fields, Class methods |
|
| 45. |
The snippet that filters the filtered set is __________(a) var t=new FilteredSet(s, {function(s) {return !(x instanceof Set);});(b) var t=new FilteredSet{function(s) {return !(x instanceof Set);});(c) var t=new FilteredSet(s, {function(s) {return (x instanceof Set);});(d) var t=new FilteredSet(s, {function(s) {return x;});The question was asked in an interview for internship.I'd like to ask this question from Classes in JavaScript topic in division Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct answer is (a) var t=new FilteredSet(s, {function(s) {return !(X INSTANCEOF Set);}); |
|
| 46. |
When a class B can extend another class A, we say that?(a) A is the superclass and B is the subclass(b) B is the superclass and A is the subclass(c) Both A and B are the superclass(d) Both A and B are the subclassThe question was asked in an internship interview.I'd like to ask this question from Classes in JavaScript in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct ANSWER is (a) A is the SUPERCLASS and B is the SUBCLASS |
|
| 47. |
The property of JSON() method is __________(a) it can be invoked manually as object.JSON()(b) it will be automatically invoked by the compiler(c) it is invoked automatically by the JSON.stringify() method(d) it cannot be invoked in any formI got this question at a job interview.Enquiry is from Classes in JavaScript in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct choice is (c) it is INVOKED automatically by the JSON.stringify() method |
|
| 48. |
The meaning for Augmenting classes is that ___________(a) objects inherit prototype properties even in a dynamic state(b) objects inherit prototype properties only in a dynamic state(c) objects inherit prototype properties in the static state(d) object doesn’t inherit prototype properties in the static stateThe question was posed to me in an online quiz.The question is from Classes in JavaScript in portion Classes and Modules in JavaScript of JavaScript |
|
Answer» The CORRECT choice is (a) objects inherit prototype properties even in a dynamic state |
|
| 49. |
The basic difference between JavaScript and Java is _________(a) There is no difference(b) Functions are considered as fields(c) Variables are specific(d) Functions are values, and there is no hard distinction between methods and fieldsI have been asked this question by my school principal while I was bunking the class.This intriguing question originated from Classes in JavaScript topic in section Classes and Modules in JavaScript of JavaScript |
|
Answer» The correct answer is (d) Functions are values, and there is no hard DISTINCTION between methods and fields |
|
| 50. |
The keyword or the property that you use to refer to an object through which they were invoked is _________(a) from(b) to(c) this(d) objectThis question was addressed to me by my school principal while I was bunking the class.Enquiry is from Classes in JavaScript topic in chapter Classes and Modules in JavaScript of JavaScript |
|
Answer» RIGHT CHOICE is (c) this To explain I WOULD say: ‘this’ KEYWORD is used to refer to the object through which the properties or methods were invoked. This use of ‘this’ is a fundamental characteristic of the methods of any class. |
|