Prototype Programming MCQs

Prototype Programming MCQs

Our experts have gathered these Prototype Programming  MCQs through research, and we hope that you will be able to see how much knowledge base you have for the subject of Prototype Programming by answering these 60+ multiple-choice questions.
Get started now by scrolling down!

1: Which of the following tags can make element draggable?

A.   p

B.   span

C.   div

D.   li

2: What is the result of the following code snippet?
el.insert("«span»Prototype«/span»");

A.   «span«Prototype«/span« will be the last child of el.

B.   «span«Prototype«/span« will be the first child of el.

C.   «span«Prototype«/span« will replace innerHTML of el.

D.   This code snippet is invalid.

3: Which of the following functions is used to call the initialize method of the parent class?

A.   $super

B.   initialize

C.   Method has the same name as parent class name.

D.   It is not possible to call the initialize method of the parent class.

4: Consider the following code snippet:

var a = {framework: "Prototype", version: "1.6.1"};
var b = a.toObject();
alert(b.version);

What does the alert box display?

A.   1.6.1

B.   null

C.   undefined

D.   This code snippet causes an error. 

5: You have a local autocomplete like the following:
new Autocompleter.Local(arg1, arg2, arg3, arg4);
Assume that you want to create a local autocomplete text field. You want to display all possible values on div1 div element and show this div to the user. Which of the following arguments is the value of div1 div?

A.   arg1

B.   arg2

C.   arg3

D.   arg4 

6: $("id1").wrap("div", {"class" : "container"});

A.   This code snippet will wrap id1 in a div tag.

B.   This code snippet will wrap div tags that have "container" class in id1 element.

C.   This code snippet is invalid.

7: What does the statement $("item1", "item2", "item3"); return?

A.   A collection of elements with item1, item2, item3 ids.

B.   A collection of elements that have one of the item1, item2, item3 classes.

C.   This statement is invalid.

8: Consider the following code snippet:
new Ajax.InPlaceEditor("id1", "save.jsp");
What is the request parameter name of id1 element on server When its value changes?

A.   id1

B.   InPlaceEditor

C.   value

D.   This code snippet is incorrect. 

9: Which of the following functions updates an existing hash?

A.   update

B.   merge

C.   delete

D.   remove 

10: PeriodicalUpdater updates an element ___

A.   at the given frequency.

B.   with the specified number of times.

C.   at the given hours.

D.   This function does not exist. 

11: What is the result of the following code snippet?
[1, null, 2, false, 3].partition();

A.   [[1, 2, 3], [null, false]]

B.   [1, 2, 3, null, false]

C.   [1, 2, 3]

D.   [null, false, 1, 2, 3] 

12: What does cleanWhiteSpace method of element do?

A.   It removes all of element's child text nodes that contain only whitespace.

B.   It removes whitespace from element.

C.   It removes whitespace from the content of all child nodes.

D.   This method does not exist.

13: Which of the following methods allows you to add class to a class after that class is defined?

A.   Class.addMethods

B.   Class.includeMethods

C.   Class.add

D.   Class.include 

14: Which of the following parameters is/are valid parameter(s) of Effect.Highlight() method?

A.   startColor

B.   end-color

C.   restorecolor

D.   border-color

15: Which of the following properties holds the number of active requests?

A.   Ajax.activeRequestCount

B.   Ajax.numberActiveRequests

C.   Ajax.activeRequests

D.  

There are no such properties.

16: If the server response time is slow, you may consider increasing the ___ option parameter to reduce the response time.

A.   frequency

B.   wait

C.   interval

17: Which of the following element methods finds siblings of that element?

A.   sibling

B.   adjacent

C.   children

D.   There is no such method

18: Consider the following code snippet: var s = "; (5).times(function(n) {    s += n; }); alert(s); What does the alert box display?

A.   01234

B.   55555

C.   10

D.   Nothing

19: The time to complete an effect generally depends on the speed of the computer.

A.   True

B.   False

20: Which of the following statements displays prototype version of Prototype?

A.   Prototype.Version

B.   $.Version

C.   VersionOf("Prototype")

D.  

VersionOf($); 

21: Consider the following code snippet:
new Effect.Scale("id1", arg2);
Which attribute(s) is id1 element scaled to?

A.   width

B.   height

C.   font

D.   border

22: Which of the following options is/are valid element(s) of the function-Form.Element.present(element)

A.   input

B.   textarea

C.   button

D.   This function is invalid.

23: Which of the following is/are a valid callback of core effects?

A.   beforeStart

B.   afterSetup

C.   beforeUpdate

D.   afterFinish 

24: What is the result of the following code snippet?
[1, 2, 3, 4, 5].map( function(num) { return num * num; } );

A.   [1, 4, 9, 16, 25]

B.   55

C.   25

D.   This code snippet causes an error. 

25: Which of the following methods allows you to add a new instance of method to a class after that class has been defined?

A.   initialize

B.   constructor

C.   Method has the same name as class name.

D.   There is no constructor of prototype class.

26: What is the difference between the names of native browser events and prototype custom events?

A.   Custom events have a colon (:) in their name.

B.   Native browser events have a colon (:) in their name.

C.   Native browser event names are case-sensitive.

D.   There are no differences 

27: Consider the following code snippet:
Sortable.create("id1");
Assume that nodes which id: id11, id12 are children of id1 and nodes which id: id111, id112 are children of id11. Which of the following elements can be sortable?

A.   id11 and id12

B.   id111 and id112

C.   all

D.   none

28: What is the valid range of $R(1, 10, true);?

A.   1 to 9

B.   1 to 10

C.   2 to 9

D.   2 to 10 

29: __________ allows more than one effects to occur at the same time.

A.   Effect.Parallel

B.   Effect.Asynchronous

C.   Effect.run

D.   There is no such method. 

30: Consider the following code snippet:
Element.addMethods({
 : show: function(element) {
 : alert("This is prototype.");
  }
});

What does this code snippet do?

A.   It adds show method to all elements.

B.   It adds show method to

C.   This code snippet is invaid.

31: If you create a draggable object, but do not create any droppable objects, then the draggable object cannot be moved by drag and drop actions.

A.   True

B.   False

32: Which of the given options is the result of the following code snippet?
new Builder.node("div", {className: "error"}, "Error");

A.   Change innerHTML of div tags that have "error" class to Error.

B.   Change class of div tags that contain "Error" to "error".

C.   Create a div tag that has "error" as class name and contains "Error" text.

D.   This code snippet is invalid.

33: Which of the following effects are core effects?

A.   Effect.Appear

B.   Effect.Opacity

C.   Effect.Tween

D.   Effect.Move

34: What is the result of the following code snippet?
[1, 2, 3, 4, 5].detect(function(n) {return n % 3});

A.   1

B.   2

C.   3

D.   5 

35: When is the Ddom:loaded event fired?

A.   Before the DOM tree is loaded.

B.   After the DOM tree is loaded, before window's load event.

C.   After load event.

D.   After an Ajax request finishes.

36: Which of the following objects allows you to monitor Ajax activities?

A.   Ajax.Responders

B.   Ajax.Monitor

C.   Ajax.Response

D.   There are no such objects.

37: Which of the following functions returns the element that occurred?

A.   Event.element

B.   Event.target

C.   Element.target

D.   Element.eventTarget 

38: What is the result of the following function?
function a() {
   var x = 10;
 return x.toPaddedString(4);
}

A.   0010

B.   000a

C.   10.00

D.   This function is invalid.

39: If you want to make an Ajax request using xml instead of the regular URL-encoded format, which option parameter do you have to change?

A.   contentType

B.   method

C.   encoding

D.   It is not possible to send request using xml. 

40:

Consider the following code snippet:
new Effect.Scale(agr1, arg2);
What is arg2 parameter?

A.   Percentage to scale

B.   Number of times to scale

C.   Width

D.   Height

41: The callback function in options of Ajax.Autocomplete() is called ___ the request is actually made

A.   before

B.   after

42: ___ extends event with all of the methods contained in Event.Methods.

A.   Event.extend

B.   Event.include

C.   Event.inherit

D.   There is no method to do so.

43: How can you stop an event from propagating?

A.   Event.stop

B.   Event.preventDefault

C.   Event.stopPropagation

D.   Event.preventPropagation

44: Which of the following statements is valid?

A.   Object.isUndefined(a);

B.   a.isUndefined();

C.   isUndefined(a);

D.   isDefined(a);

45: What does $F(element).getValue() return?

A.   It returns the current value of a form control.

B.   It returns the value of function $F.

C.   It returns the value of any given element.

D.   This function is invalid. 

46: Consider the following code snippet:
var template = new Template("This is #{framework} version #{version}");
var a = {framework: "Prototype", version: "1.6.1"}
var b = template.evaluate(a);
What is the result of b?

A.   This is Prototype version 1.6.1

B.   This is #{framework} version #{version}

C.   This is 1.6.1 version Prototype

D.   This code snippet is invalid 

47: Which of the following code snippets is the proper way to define a class that inherits another class?

A.   var Dog = Class.create(Animal, {});

B.   var Dog = Class.inherit(Animal, {});

C.   var Dog = Class.extend(Animal, {});

D.   var Dog = Animal.extend({});

48: Which of the following methods allows you to set many style attributes in one call?

A.   setStyle

B.   setStyles

C.   setAttribute

D.   setAttributes 

49: Which of the following code snippets moves id1 element?

A.   new Effect.Move("id1", {0, 0, 'relative'});

B.   "id1".Move("x: 0; y: 0");

C.   "id1".Move(x: 0, y: 0, "left");

D.   new Effect.Move(

50: Which of the following functions converts html special characters to their entity equivalents?

A.   escapeHTML

B.   escape

C.   removeHTML

D.   convertHTML