Classes And Modules — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Classes And Modules — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The behaviour of the instances present of a class inside a method is defined by
Correct Answer: Option B — Classes
Detailed Academic Explanation:
The behaviour of the instance of a class is defined by the class and is shared by all instances.
💡Key Conceptual Anchor:Classes And Modules
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The keyword or the property that you use to refer to an object through which they were invoked is
Correct Answer: Option C — this
Detailed Academic Explanation:
The ‘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.
💡Key Conceptual Anchor:Classes And Modules
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Consider the following code snippet : var o = new F () ; o . constructor === F The output would be :
Correct Answer: Option B — true
Detailed Academic Explanation:
The result is true: the constructor property specifies the class.
💡Key Conceptual Anchor:Classes And Modules
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The basic difference between JavaScript and Java is
Correct Answer: Option D — Functions are values, and there is no hard distinction between methods and fields
Detailed Academic Explanation:
The basic difference between JavaScript and Java is that the functions are values, and there is no hard distinction between methods and fields.
💡Key Conceptual Anchor:Classes And Modules
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The meaning for Augmenting classes is that
Correct Answer: Option A — objects inherit prototype properties even in dynamic state
Detailed Academic Explanation:
JavaScript’s prototype-based inheritance mechanism is dynamic: an object inherits properties from its prototype, even if the prototype changes after the object is created. This means that we can augment JavaScript classes simply by adding new methods to their prototype objects.
💡Key Conceptual Anchor:Classes And Modules
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The property of JSON() method is:
Correct Answer: Option C — it is invoked automatically by the JSON.stringify() method
Detailed Academic Explanation:
The JSON format is intended for serialization of data structures and can handle JavaScript primitive values, arrays, and plain objects. It does not know about classes, and when serializing an object, it ignores the object’s prototype and constructor. If you call JSON.stringify() on a Range or Complex object, for example, it returns a string like {“from”:1, “to”:3} or {“r”:1, “i”:-1}.
💡Key Conceptual Anchor:Classes And Modules
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When a class B can extend another class A, we say that
Correct Answer: Option A — A is the superclass and B is the subclass
Detailed Academic Explanation:
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.
💡Key Conceptual Anchor:Classes And Modules
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If A is the superclass and B is the subclass, then subclass inherting the superclass can be represented as
Correct Answer: Option C — B.prototype=inherit(A)
Detailed Academic Explanation:
The subclass B inherits the prototype of the class A.
💡Key Conceptual Anchor:Classes And Modules
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The method that can be used to create new properties and also to modify the attributes of existing properties is
Correct Answer: Option C — Both Object.defineProperty() and Object.defineProperties()
Detailed Academic Explanation:
When used to define new properties, any attributes you omit default to false. Therefore, both Object.defineProperty() and Object.defineProperties() can be used to create and modify the attributes.
💡Key Conceptual Anchor:Classes And Modules
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The four kinds of class members are
Correct Answer: Option B — Instance fields, Instance methods, Class fields, Class methods
Detailed Academic Explanation:
The four kinds of class members are Instance fields, Instance methods, Class fields, Class methods.
💡Key Conceptual Anchor:Classes And Modules
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The properties of the objects act like different kinds of class members. They are
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.
💡Key Conceptual Anchor:Classes And Modules
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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
Correct Answer: Option D — Prototype object
Detailed Academic 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.
💡Key Conceptual Anchor:Classes And Modules
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which are usually variables that are used internally in object methods and also are globally visible variables?
Correct Answer: Option B — Variable properties
Detailed Academic 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.
💡Key Conceptual Anchor:Classes And Modules
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The class that represents the regular expressions is
Correct Answer: Option C — RegExp
Detailed Academic Explanation:
The JavaScript RegExp class represents regular expressions, and both string and RegExp define methods that use regular expressions.
💡Key Conceptual Anchor:Classes And Modules
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is the correct code that returns a complex number that is the complex conjugate of this one?
Correct Answer: Option A — Complex.prototype.conj = function() { return new Complex(this.r, -this.i); }
Detailed Academic Explanation:
The above code snippet returns a complex number that is the complex conjugate of this one.
💡Key Conceptual Anchor:Classes And Modules
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can we make methods available on all objects?
Correct Answer: Option D — Object.prototype
Detailed Academic 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 nonenumerable, and if you add properties to Object.prototype , those properties will be reported by all for/in loops.
💡Key Conceptual Anchor:Classes And Modules
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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?
Correct Answer: Option B — HTMLElement.prototype
Detailed Academic Explanation:
It is implementation-dependent whether classes defined by the host environment (such as the web browser) can be augmented using Object.prototype . In many web browsers, for example, you can add methods to HTMLElement.prototype and those methods will be inherited by the objects that represent the HTML tags in the current document.
💡Key Conceptual Anchor:Classes And Modules
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
You can refresh the webpage in JavaScript by using
Correct Answer: Option B — location.reload
Detailed Academic Explanation:
One can refresh the webpage in JavaScript by using location.reload .
💡Key Conceptual Anchor:Classes And Modules
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The functions provide() and require() of Dojo toolkit and Google’s Closure library are used for
Correct Answer: Option A — declaring and loading modules
Detailed Academic Explanation:
Both the Dojo toolkit and Google’s Closure library define provide() and require() functions for declaring and loading modules.
💡Key Conceptual Anchor:Classes And Modules
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The maximum number of global symbols a module can define is
Correct Answer: Option C — 1
Detailed Academic Explanation:
Generally, the various modules are allowed to run in the pristine (or near pristine) environment that it expects. The modules should minimize the number of global symbols they define – ideally, no module should define more than one.
💡Key Conceptual Anchor:Classes And Modules
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
To define each of the set classes as a property of the sets object (namespace) for the module, the statement is
Correct Answer: Option B — sets.SingletonSet = sets.AbstractEnumerableSet.extend(...)
Detailed Academic Explanation:
The sets object is the namespace for the module, and we define each of the set classes as a property of this object.
💡Key Conceptual Anchor:Classes And Modules
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Consider the following statement var Set = sets . Set; var s = new Set ( 1 , 2 , 3 ) ; What could be the efficiency quotient of the above two statements ?
Correct Answer: Option A — The programmer imports at once the frequently used values into the global namespace
Detailed Academic Explanation:
A programmer can import frequently used values into the global namespace. A programmer who was going to make frequent use of the Set class from the sets namespace might import the class like that.
💡Key Conceptual Anchor:Classes And Modules
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The scope of a function is also called as
Correct Answer: Option B — Module function
Detailed Academic Explanation:
The scope of a function can be used as a private namespace for a module. Therefore, the scope of a function is called a module function .
💡Key Conceptual Anchor:Classes And Modules
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Modules that have more than one item in their API can
Correct Answer: Option C — Return a namespace object
Detailed Academic Explanation:
Modules that have more than one item in their API can return a namespace object.
💡Key Conceptual Anchor:Classes And Modules
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The provides() function and the exportsobject are used to
Correct Answer: Option A — Register the module’s API and Store their API
Detailed Academic 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.
💡Key Conceptual Anchor:Classes And Modules
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Consider the following code snippet var sets = com . davidflanagan . collections . sets; What is the programmer trying to do in the above code snippet?
Correct Answer: Option D — Importing the entire module
Detailed Academic Explanation:
Rather than importing individual classes, a programmer might import the entire module to the global namespace.
💡Key Conceptual Anchor:Classes And Modules
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The properties() method is a
Correct Answer: Option B — Non-enumerable method
Detailed Academic Explanation:
The properties() method is a non-enumerable method.
💡Key Conceptual Anchor:Classes And Modules
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What can be done in order to avoid creation of global variables in JavaScript?
Correct Answer: Option C — To use an object as its namespace
Detailed Academic 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).
💡Key Conceptual Anchor:Classes And Modules
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The ‘$’ present in the RegExp object is called a
Correct Answer: Option C — metacharacter
Detailed Academic Explanation:
The ‘S’ is a special metacharacter that matches the end of a string.
💡Key Conceptual Anchor:Classes And Modules
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Consider the following statement containing regular expressions var text = "testing: 1, 2, 3" ; var pattern = / d +/ g; In order to check if the pattern matches, the statement is
Correct Answer: Option D — pattern.test(text)
Detailed Academic Explanation:
The given pattern is applied on the text given in the paranthesis.
💡Key Conceptual Anchor:Classes And Modules
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The regular expression to match any one character not between the brackets is
Correct Answer: Option C — [^…]
Detailed Academic Explanation:
The [^…] character class is used to match or draw any one character not between the brackets.
💡Key Conceptual Anchor:Classes And Modules
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does /[^(]* regular expression indicate ?
Correct Answer: Option C — Match zero or more characters that are not open paranthesis
Detailed Academic Explanation:
We should always be careful while using * and ? as repetition characters as they may match zero instances of whatever precedes them, they are allowed to match nothing.
💡Key Conceptual Anchor:Classes And Modules
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the result when non greedy repetition is used on the pattern /a+?b/ ?
Correct Answer: Option A — Matches the letter b preceded by the fewest number of a’s possible
Detailed Academic Explanation:
Using non greedy repetition may not always produce the results you expect. /a+?b/ matches the letter b preceded by the fewest number of a’s possible.
💡Key Conceptual Anchor:Classes And Modules
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the subexpression /java(script)?/ result in ?
Correct Answer: Option A — It matches “java” followed by the optional “script”
Detailed Academic Explanation:
The subexpression /java(script)?/ matches “java” followed by the optional “script”.
💡Key Conceptual Anchor:Classes And Modules
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the most essential purpose of parantheses in regular expressions ?
Correct Answer: Option B — Define subpatterns within the complete pattern
Detailed Academic Explanation:
When a regular expression is successfullyy matched against a target string, it is possible to extract the portions of the target string that matched any particular paranthesized subpattern. The essential purpose of parantheses in regular expressions is to define subpatterns within the complete pattern.
💡Key Conceptual Anchor:Classes And Modules
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The method that performs the search-and-replace operation to strings for pattern matching is
Correct Answer: Option B — add()
Detailed Academic Explanation:
The replace() method performs a search-and-replace operation. It takes a regular expression as its first argument and a replacement string as its second argument.
💡Key Conceptual Anchor:Classes And Modules
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What would be the result of the following statement in JavaScript using regular expression methods ?
Correct Answer: Option B — Returns [“123″,”456″,”789”]
Detailed Academic Explanation:
The split() method can take regular expressions as its arguments. The split() method generally breaks the string on which it is called into an array of substrings, using the argument as a separator.
💡Key Conceptual Anchor:Classes And Modules
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The Crockford’s subset doesnot include which function in JavaScript?
Correct Answer: Option A — eval()
Detailed Academic 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.
💡Key Conceptual Anchor:Classes And Modules
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Why does JavaScript subset disallow == and !=?
Correct Answer: Option B — It uses === and !== instead
Detailed Academic 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.
💡Key Conceptual Anchor:Classes And Modules
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is being imposed on each subset to ensure that it conforms to the subset?
Correct Answer: Option C — A static verifier that parses code
Detailed Academic Explanation:
Each subset is coupled with a static verifier that parses code to ensure that it conforms to the subset.
💡Key Conceptual Anchor:Classes And Modules
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.