Pro Coder Quiz

CapDev Harbinger Group

ProCoder Quiz of the Month - Oct 2023

Top 3 Winners:
Sayali Gole, Azher Sofi and Niranjan Dhumal

Congratulations!!

Quiz Questions and answers are below:

1. Which of the following is considered a first class citizen in JavaScript? 
   A) Functions
   B) Class
   C) Array
   D) Object
Correct Answer: Option A

2. What is the right syntax to accept an indefinite number of parameters?
   A) Function sum(...theArgs) {}
   B) Function sum(theArgs...) {}
   C) Function sum(theArgs) {}
   D) Function sum([theArgs]) {}
Correct Answer: Option A

3. What will be the output of the following code snippet?

    (function(){
     setTimeout(()=> console.log(1),2000);
     console.log(2);
     setTimeout(()=> console.log(3),0);
     console.log(4);
    })();   


   A)  1 2 3 4
   B) 2 3 4 1 
   C) 2 4 3 1
   D) 4 3 2 1 
Correct Answer: Option C

4. What will be the output of the following code snippet?   
    
    var a = true + true + true * 3;
    print(a)

   A) 3
   B) 0
   C) Error
   D)
Correct Answer: Option D

5. The process in which an object or data structure is translated into a format suitable for transferral over a network, or storage is called?    
   A) Object Serialization
   B) Object Encapsulation
   C) Object Inheritance
   D) None of the above
Correct Answer: Option A

6. What will be the output of the following code snippet?

print(parseInt("123Hello"));
    print(parseInt("Hello123"));

   A) 123 NaN
   B) 123Hello Hello123
   C) NaN NaN
   D) 123 123
Correct Answer: Option A

7. Which of the following scoping type does JavaScript use?
   A) Sequential
   B) Segmental
   C) Lexical
   D) Literal
Correct Answer: Option C

8. What will be the result or type of error if p is not defined in the following JavaScript code snippet?

console.log(p)

   A) Value not found Error
   B) Reference Error 
   C) Null
   D) Zero
Correct Answer: Option B

9. What does the following JavaScript code snippet do?

data.sort(function(a,b),b-a);   

   A) Sort in the alphabetical order
   B) Sort in the chronological order
   C) Sort in reverse alphabetical order
   D) Sort in reverse numerical order
Correct Answer: Option D

10. What will be the role of the continue keyword in the following JavaScript code snippet?

while (a != 0)
    {
       if (a == 1)
           continue;
       else
           a++;
    }   

   A) The continue keyword restarts the loop
   B) The continue keyword skips the next iteration
   C) The continue keyword skips the rest of the statements in that iteration
   D) The continue keyword breaks out of the loop
Correct Answer: Option C

11. 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 order
Correct Answer: Option A

12. 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 array   
Correct Answer: Option C

13.  What will be the output of the following JavaScript code?

function output(object)
    {
        var place=object ? object.place : “Italy”;
        return “Name:”+ place;
    }
    console.log(output({place:India}));   

   A) Name:India
   B) Name:Italy
   C) error
   D) undefined
Correct Answer: Option A

14. What will be the last statement return in the following JavaScript code?

function constfuncs()
    {
        var funcs = [];
        for(var i = 0; i < 10; i++)
            funcs[i] = function() { return i; };
        return funcs;
    }
    var funcs = constfuncs();
    funcs[5]()   

   A) 9
   B) 0
   C) 10
   D) 12
Correct Answer: Option C

15. What will be the output of the following JavaScript code?

var person =
    { 
          name: “Rahul”, 
          getName: function()
          { 
              return this.name; 
          } 
    }
    var unboundName = person.getName; 
    var boundName = unboundName.bind(person); 
    document.writeln(boundName());   

   A) runtime error;
   B) compilation error
   C) Rahul
   D) undefined
Correct Answer: Option C


Last modified: Monday, 16 October 2023, 3:48 PM