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. |
What is the purpose of the dynamic scoping?(a) Variables can be declared outside the scope(b) Variables must be declared outside the scope(c) Variables cannot be declared outside the scope(d) Variable cannot be declared within the functionThis question was addressed to me during an online exam.Asked question is from Closures in section Lexical Structures of JavaScript |
|
Answer» Correct option is (a) Variables can be DECLARED outside the scope |
|
| 2. |
What is the opposite approach to the lexical scoping?(a) Literal scoping(b) Static scoping(c) Dynamic scoping(d) Generic scopingThis question was posed to me in a job interview.Origin of the question is Closures topic in division Lexical Structures of JavaScript |
|
Answer» The correct OPTION is (c) Dynamic scoping |
|
| 3. |
What is the fundamental rule of lexical scoping?(a) Functions are declared in the scope(b) Functions are executed using scope chain(c) Functions are declared outside the scope(d) Variables are declared within the functionI have been asked this question during a job interview.I'd like to ask this question from Closures in portion Lexical Structures of JavaScript |
|
Answer» CORRECT ANSWER is (b) Functions are EXECUTED USING scope chain The best I can explain: The FUNDAMENTAL rule of lexical scoping is that the JavaScript functions are executed using the scope chain that was in effect when they were defined. |
|
| 4. |
Which of the following uses a lot of CPU cycles?(a) GUI(b) Statically generated graphics(c) Dynamically generated graphics(d) Generic scopingThe question was posed to me in a job interview.I would like to ask this question from Closures in section Lexical Structures of JavaScript |
|
Answer» Correct choice is (c) Dynamically generated graphics |
|
| 5. |
Which of the following is not an example of closures?(a) Objects(b) Variables(c) Functions(d) GraphicsI got this question in homework.This interesting question is from Closures topic in portion Lexical Structures of JavaScript |
|
Answer» RIGHT CHOICE is (d) Graphics For EXPLANATION: In JavaScript, closures are created EVERY time a function is created, at function creation time. Technically, all JavaScript functions are closures: they are objects, and they have a scope CHAIN associated with them. |
|
| 6. |
What is closure?(a) Function objects(b) Scope where function’s variables are resolved(c) Both Function objects and Scope where function’s variables are resolved(d) Function return valueThe question was posed to me in an interview for internship.This intriguing question originated from Closures topic in portion Lexical Structures of JavaScript |
|
Answer» The correct choice is (c) Both Function objects and Scope where function’s VARIABLES are RESOLVED |
|
| 7. |
What must be done in order to implement Lexical Scoping?(a) Get the object(b) Dereference the current scope chain(c) Reference the current scope chain(d) Return the valueThe question was posed to me during an interview.Enquiry is from Closures topic in section Lexical Structures of JavaScript |
|
Answer» The correct choice is (C) REFERENCE the current scope chain |
|
| 8. |
What kind of scoping does JavaScript use?(a) Literal(b) Lexical(c) Segmental(d) SequentialI had been asked this question in quiz.I'd like to ask this question from Closures in section Lexical Structures of JavaScript |
|
Answer» The correct CHOICE is (B) LEXICAL |
|
| 9. |
A function with no return value is called ___________(a) Procedures(b) Method(c) Static function(d) Dynamic functionI have been asked this question in a job interview.Origin of the question is Defining and Invoking Functions in portion Lexical Structures of JavaScript |
|
Answer» Correct option is (a) Procedures |
|
| 10. |
Which keyword is used to define the function in javascript?(a) void(b) int(c) function(d) mainI got this question during an internship interview.This key question is from Defining and Invoking Functions topic in chapter Lexical Structures of JavaScript |
|
Answer» Right option is (c) function |
|
| 11. |
The function stops its execution when it encounters?(a) continue statement(b) break statement(c) goto statement(d) return statementI had been asked this question in a job interview.This is a very interesting question from Defining and Invoking Functions topic in chapter Lexical Structures of JavaScript |
|
Answer» The correct choice is (d) return statement |
|
| 12. |
What will happen if a return statement does not have an associated expression?(a) It returns the value 0(b) It will throw an exception(c) It returns the undefined value(d) It will throw an errorI got this question in examination.This intriguing question comes from Defining and Invoking Functions in chapter Lexical Structures of JavaScript |
|
Answer» Correct choice is (c) It returns the UNDEFINED VALUE |
|
| 13. |
What is the purpose of a return statement in a function?(a) Returns the value and continues executing rest of the statements, if any(b) Returns the value and stops the program(c) Returns the value and stops executing the function(d) Stops executing the function and returns the valueThis question was posed to me in exam.Question is taken from Defining and Invoking Functions in chapter Lexical Structures of JavaScript |
|
Answer» RIGHT choice is (d) Stops executing the function and RETURNS the value The best I can explain: The return stops the execution of the function when it is encountered within the function. It returns the value to the statement where the function is CALLED. |
|
| 14. |
When does the function name become optional in JavaScript?(a) When the function is defined as a looping statement(b) When the function is defined as expressions(c) When the function is predefined(d) when the function is calledI have been asked this question in quiz.I'm obligated to ask this question of Defining and Invoking Functions in section Lexical Structures of JavaScript |
|
Answer» Correct OPTION is (b) When the FUNCTION is defined as EXPRESSIONS |
|
| 15. |
The function definitions in JavaScript begins with _____________(a) Identifier and Parentheses(b) Return type and Identifier(c) Return type, Function keyword, Identifier and Parentheses(d) Identifier and Return typeThis question was addressed to me during an interview.The doubt is from Defining and Invoking Functions topic in section Lexical Structures of JavaScript |
|
Answer» Correct ANSWER is (c) RETURN type, Function keyword, Identifier and Parentheses |
|
| 16. |
The reduce and reduceRight methods follow a common operation called __________(a) filter and fold(b) inject and fold(c) finger and fold(d) foldThis question was addressed to me in an internship interview.The question is from Array and Related Methods topic in portion Lexical Structures of JavaScript |
|
Answer» Correct choice is (b) inject and fold |
|
| 17. |
The primary purpose of the array map() function is that it __________(a) maps the elements of another array into itself(b) passes each element of the array and returns the necessary mapped elements(c) passes each 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(d) pass the elements of the array into another arrayThis question was addressed to me in exam.Origin of the question is Array and Related Methods topic in section Lexical Structures of JavaScript |
|
Answer» Correct option is (c) PASSES each 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 |
|
| 18. |
What will happen if reverse() and join() methods are used simultaneously?(a) Reverses and stores in the same array(b) Reverses and concatenates the elements of the array(c) Reverses(d) Stores the elements of an array in normal orderThe question was asked in an online interview.My question is taken from Array and Related Methods topic in division Lexical Structures of JavaScript |
|
Answer» Correct OPTION is (a) Reverses and STORES in the same array |
|
| 19. |
The pop() method of the array does which of the following task?(a) decrements the total length by 1(b) increments the total length by 1(c) prints the first element but no effect on the length(d) updates the elementI had been asked this question by my college director while I was bunking the class.I'd like to ask this question from Array and Related Methods topic in division Lexical Structures of JavaScript |
|
Answer» The correct CHOICE is (a) decrements the TOTAL LENGTH by 1 |
|
| 20. |
The purpose of extensible attribute is to __________(a) make all of the own properties of that object non configurable(b) to configure and bring a writable property(c) “lock down” objects into a known state and prevent outside tampering(d) to include new properties into the objectI got this question during an interview.Asked question is from Object Attributes and Serialization topic in section Lexical Structures of JavaScript |
|
Answer» RIGHT choice is (c) “LOCK down” objects into a known state and prevent outside tampering Easiest explanation: Extensible attributes DETERMINES whether the object can have new properties or not. THEREFORE extensible attribute will allow an object to include and write properties into them. |
|
| 21. |
To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the ____________(a) isPrototypeOf() method(b) equals() method(c) === operator(d) ==opertorThis question was posed to me during an interview for a job.The question is from Object Attributes and Serialization in division Lexical Structures of JavaScript |
|
Answer» RIGHT option is (a) isPrototypeOf() method To EXPLAIN I would say: Prototype is a global property which is available with ALMOST all the objects. To determine whether one object is the prototype of (or is part of the prototype CHAIN of) another object, one should use the isPrototype() method. To find out if P is the prototype of o write p.isPrototypeOf(o). |
|
| 22. |
A linkage of series of prototype objects is called as ________(a) prototype stack(b) prototype chain(c) prototype class(d) prototypesI had been asked this question in a job interview.Origin of the question is Object Attributes and Serialization in chapter Lexical Structures of JavaScript |
|
Answer» Right option is (b) prototype chain |
|
| 23. |
The unordered collection of properties, each of which has a name and a value is called _________(a) String(b) Object(c) Serialized Object(d) ArrayThe question was asked in an online quiz.Enquiry is from Object Attributes and Serialization topic in portion Lexical Structures of JavaScript |
|
Answer» The correct answer is (B) Object |
|
| 24. |
The object has three object attributes namely ________(a) Class, parameters, object’s extensible flag(b) Prototype, class, objects’ parameters(c) Prototype, class, object’s extensible flag(d) Native object, Classes and Interfaces and Object’s extensible flagThis question was posed to me in an online interview.This intriguing question originated from Object Attributes and Serialization topic in division Lexical Structures of JavaScript |
|
Answer» Correct answer is (C) PROTOTYPE, CLASS, object’s extensible flag |
|
| 25. |
What will be the step of the interpreter in a jump statement when an exception is thrown?(a) The interpreter stops its work(b) The interpreter throws another exception(c) The interpreter jumps to the nearest enclosing exception handler(d) The interpreter throws an errorI have been asked this question at a job interview.My question is taken from Loops in JavaScript in portion Lexical Structures of JavaScript |
|
Answer» Right OPTION is (c) The INTERPRETER jumps to the nearest ENCLOSING exception handler |
|
| 26. |
The “var” and “function” are __________(a) Keywords(b) Declaration statements(c) Data types(d) PrototypesI got this question by my college professor while I was bunking the class.This question is from Statements in portion Lexical Structures of JavaScript |
|
Answer» CORRECT answer is (b) DECLARATION statements The explanation is: The var and function are declaration statements—they declare or define variables and functions. These statements define identifiers (variable and function names) that can be USED elsewhere in your PROGRAM and ASSIGN values to those identifiers. |
|
| 27. |
When an empty statement is encountered, a JavaScript interpreter __________(a) Ignores the statement(b) Prompts to complete the statement(c) Throws an error(d) Shows a warningI got this question in class test.This intriguing question originated from Statements in division Lexical Structures of JavaScript |
|
Answer» The correct choice is (a) Ignores the statement |
|
| 28. |
What is a block statement in JavaScript?(a) conditional block(b) block that contains a single statement(c) both conditional block and a single statement(d) block that combines multiple statements into a single compound statementI got this question in quiz.I want to ask this question from Statements in section Lexical Structures of JavaScript |
|
Answer» Correct OPTION is (d) block that combines MULTIPLE statements into a single COMPOUND statement |
|
| 29. |
A function definition expression can be called as __________(a) Function prototype(b) Function literal(c) Function calling(d) Function declarationThe question was posed to me in an online interview.This interesting question is from Expressions and Operators topic in section Lexical Structures of JavaScript |
|
Answer» The correct choice is (B) Function literal |
|
| 30. |
The snippet that has to be used to check if “a” is not equal to “null” is _________(a) if(a!=null)(b) if (!a)(c) if(a!null)(d) if(a!==null)I got this question in semester exam.My enquiry is from Types, Values and Variables in section Lexical Structures of JavaScript |
|
Answer» Correct OPTION is (d) if(a!==null) |
|
| 31. |
JavaScript is a _______________ language.(a) Object-Oriented(b) High-level(c) Assembly-language(d) Object-BasedThis question was addressed to me in an internship interview.I want to ask this question from Statements topic in chapter Lexical Structures of JavaScript |
|
Answer» The correct CHOICE is (d) Object-Based |
|
| 32. |
The statement a===b refers to _________(a) Both a and b are equal in value, type and reference address(b) Both a and b are equal in value(c) Both a and b are equal in value and type(d) There is no such statementI got this question in an international level competition.I would like to ask this question from Types, Values and Variables in chapter Lexical Structures of JavaScript |
|
Answer» The CORRECT answer is (c) Both a and b are equal in VALUE and type |
|
| 33. |
The escape sequence ‘\f’ stands for _________(a) Floating numbers(b) Representation of functions that returns a value(c) \f is not present in JavaScript(d) Form feedThe question was asked in my homework.My enquiry is from Types, Values and Variables topic in section Lexical Structures of JavaScript |
|
Answer» CORRECT option is (d) FORM feed To elaborate: \f is the JavaScript escape SEQUENCE that stands for Form feed (\u000C). It skips to the start of the NEXT page. (APPLIES mostly to terminals where the output device is a printer rather than a VDU). |
|
| 34. |
JavaScript _________ when there is an indefinite or an infinite value during an arithmetic computation.(a) Prints an exception error(b) Prints an overflow error(c) Displays “Infinity”(d) Prints the value as suchThis question was posed to me in an interview for internship.I need to ask this question from Types, Values and Variables topic in portion Lexical Structures of JavaScript |
|
Answer» Right answer is (c) DISPLAYS “INFINITY” |
|
| 35. |
Which of the following is not considered as an error in JavaScript?(a) Syntax error(b) Missing of semicolons(c) Division by zero(d) Missing of BracketThis question was posed to me during an online interview.The query is from Types, Values and Variables in portion Lexical Structures of JavaScript |
|
Answer» Right option is (C) Division by zero |
|
| 36. |
A hexadecimal literal begins with __________(a) 00(b) 0x(c) 0X(d) Both 0x and 0XThe question was posed to me in quiz.My question comes from Types, Values and Variables in chapter Lexical Structures of JavaScript |
|
Answer» Correct choice is (d) Both 0X and 0X |
|
| 37. |
The generalised syntax for a real number representation is __________(a) [digits][.digits][(E|e)[(+|-)]digits](b) [digits][+digits][(E|e)[(+|-)]digits](c) [digits][(E|e)[(+|-)]digits](d) [.digits][digits][(E|e)[(+|-)]digits]I had been asked this question in class test.Question is taken from Types, Values and Variables topic in chapter Lexical Structures of JavaScript |
|
Answer» Correct option is (a) [digits][.digits][(E|e)[(+|-)]digits] |
|
| 38. |
JavaScript Code can be called by using ___________(a) RMI(b) Triggering Event(c) Preprocessor(d) Function/MethodI got this question during an online exam.The query is from Types, Values and Variables topic in division Lexical Structures of JavaScript |
|
Answer» The correct OPTION is (d) Function/Method |
|
| 39. |
The type of a variable that is volatile is _______________(a) Volatile variable(b) Mutable variable(c) Immutable variable(d) Dynamic variableI have been asked this question in a job interview.The doubt is from Types, Values and Variables in section Lexical Structures of JavaScript |
|
Answer» The correct option is (B) Mutable VARIABLE |
|
| 40. |
JavaScript can be written __________(a) directly into JS file and included into HTML(b) directly on the server page(c) directly into HTML pages(d) directly into the css fileThe question was asked during an online exam.This question is from Lexical Structure in section Lexical Structures of JavaScript |
|
Answer» The CORRECT answer is (a) directly into JS file and included into HTML |
|
| 41. |
Which of the following Attribute is used to include External JS code inside your HTML Document?(a) src(b) ext(c) script(d) linkThe question was asked during an interview.I'm obligated to ask this question of Lexical Structure topic in portion Lexical Structures of JavaScript |
|
Answer» The correct option is (a) src |
|
| 42. |
JavaScript Code can be called by using ____________(a) RMI(b) Triggering Event(c) Preprocessor(d) Function/MethodThe question was posed to me in an international level competition.My question comes from Lexical Structure in portion Lexical Structures of JavaScript |
|
Answer» Correct ANSWER is (d) Function/Method |
|
| 43. |
Which attribute is used to specify that the script is executed when the page has finished parsing? (only for external scripts)(a) parse(b) a sync(c) defer(d) typeThe question was posed to me in class test.The question is from Lexical Structure topic in chapter Lexical Structures of JavaScript |
|
Answer» RIGHT OPTION is (C) defer The best explanation: The defer attribute is a BOOLEAN attribute. When present, it specifies that the script is executed when the PAGE has finished parsing. |
|
| 44. |
JavaScript is ideal to ________(a) make computations in HTML simpler(b) minimize storage requirements on the web server(c) increase the download time for the client(d) increase the loading time of the websiteThis question was posed to me in an online interview.My question comes from Lexical Structure topic in division Lexical Structures of JavaScript |
|
Answer» Correct choice is (b) minimize STORAGE requirements on the web server |
|
| 45. |
A JavaScript program developed on a Unix Machine ________(a) will throw errors and exceptions(b) must be restricted to a Unix Machine only(c) will work perfectly well on a Windows Machine(d) will be displayed as a JavaScript text on the browserThe question was asked by my college director while I was bunking the class.This interesting question is from Lexical Structure in division Lexical Structures of JavaScript |
|
Answer» Right answer is (c) will work perfectly well on a Windows Machine |
|
| 46. |
The script tag must be placed in __________(a) the head tag(b) the head or body(c) the title or head(d) after the body tagI had been asked this question in an internship interview.The above asked question is from Lexical Structure in portion Lexical Structures of JavaScript |
|
Answer» Correct ANSWER is (B) the head or body |
|
| 47. |
The main purpose of a “Live Wire” in NetScape is to ________(a) Create linkage between client side and server side(b) Permit server side, JavaScript code, to connect to RDBMS(c) Support only non relational database(d) To interpret JavaScript codeI got this question in class test.Enquiry is from Lexical Structure topic in division Lexical Structures of JavaScript |
|
Answer» Right CHOICE is (b) PERMIT SERVER side, JavaScript code, to connect to RDBMS |
|
| 48. |
The web development environment (JavaScript) offers which standard construct for data validation of the input entered by the user.(a) Controlled loop constructs(b) Server page access(c) Client side Event(d) Permit server-sideI have been asked this question at a job interview.I'd like to ask this question from Lexical Structure in chapter Lexical Structures of JavaScript |
|
Answer» The correct answer is (a) Controlled loop constructs |
|