Knowledge of Prototype Skills Test Answers



1. Which of the following ways can you use to check whether prototype is loaded or not?
Answers:
• typeof(Prototype) === "object"
• typeof(Prototype) == "String"
• typeof(Prototype) == "function"
• There is no way to do that.

2. 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?
Answers:
• id11 and id12
• id111 and id112
• all
• none
3. Which of the following statements displays prototype version of Prototype?
Answers:
• Prototype.Version
• $.Version
• VersionOf("Prototype")
• VersionOf($);
4. Which of the given options is the result of the following code snippet?

new Builder.node("div", {className: "error"}, "Error");
Answers:
• Change innerHTML of div tags that have "error" class to Error.
• Change class of div tags that contain "Error" to "error".
• Create a div tag that has "error" as class name and contains "Error" text.
• This code snippet is invalid.
5. Which of the following parameters is/are valid parameter(s) of Effect.Highlight() method?
Answers:
• startColor
• end-color
• restorecolor
• border-color
6. What is the result of "thisisprototype".camelize(); statement?
Answers:
• thisisprototype
• thisIsPrototype
• ThisIsPrototype
• THISISPROTOTYPE
7. What is the valid range of $R(1, 10, true);?
Answers:
• 1 to 9
• 1 to 10
• 2 to 9
• 2 to 10
8. What is the result of the following code snippet?

el.insert("«span»Prototype«/span»");
Answers:
• «span«Prototype«/span« will be the last child of el.
• «span«Prototype«/span« will be the first child of el.
• «span«Prototype«/span« will replace innerHTML of el.
• This code snippet is invalid.
9. Consider the following code snippet:

new Effect.Scale("id1", arg2);

Which attribute(s) is id1 element scaled to?
Answers:
• width
• height
• font
• border
10. What is the value of $A($R('ab', 'ah'));?
Answers:
• ["ab", "ac", "ad", "ae", "af", "ag", "ah"]
• ["ac", "ad", "ae", "af", "ag"]
• ["ab", "ac", "ad", "ae", "af", "ag"]
• This statement is invalid.
11. Which of the following options is/are valid element(s) of the function-
Form.Element.present(element);
Answers:
• input
• textarea
• button
• This function is invalid.
12. Which of the given values can be the value of arg in the following code snippet?

$("id1").insert(arg);
Answers:
• "<span>Prototype</span>"
• $("id2");
• new Element("span", "Prototype");
13. 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?
Answers:
• 1.6.1
• null
• undefined
• This code snippet causes an error.
14. What is the result of b in the following code snippet?

var a = {name: "Prototype", version: "1.6.1"}
var b = Object.values(a);
Answers:
• ["Prototype", "1.6.1"]
• {name: "Prototype", version: "1.6.1"}
• [[name, "Prototype"], [version, "1.6.1"]]
• [{name: "Prototype"}, {version: "1.6.1"}]
15. Consider the following code snippet:

new Effect.Scale(agr1, arg2);

What is arg2 parameter?
Answers:
• Percentage to scale
• Number of times to scale
• Width
• Height
16. Which of the following tags can make element draggable?
Answers:
• p
• span
• div
• li
17. Which of the following methods can you use to fade in an element?
Answers:
• Effect.FadeIn();
• Effect.Fade();
• Effect.Show();
• Effect.Appear();
18. You ___ create instances of Ajax.Response yourself.
Answers:
• do not need to
• have to
• can not
• are not allowed to
19. Which of the following methods allows you to set many style attributes in one call?
Answers:
• setStyle
• setStyles
• setAttribute
• setAttributes
20. Which of the following objects allows you to monitor Ajax activities?
Answers:
• Ajax.Responders
• Ajax.Monitor
• Ajax.Response
• There are no such objects.
21. 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?
Answers:
• arg1
• arg2
• arg3
• arg4
22. What is the result of the following code snippet?
[1, 2, 3, 4, 5].map( function(num) { return num * num; } );
Answers:
• [1, 4, 9, 16, 25]
• 55
• 25
• This code snippet causes an error.
23. Consider the following code snippet:

var Animal = Class.create({initialize: function(wildOrNot, canFly) {this.wildOrNot = WildOrNot; this.canFly = canfly;}});
var Wolf = Class.create(Animal, {initialize: function($super, arg2) {$super("Wild", false); this.leatherColor = arg2}});

Which of the following is the proper way to create a Wolf object?
Answers:
• var aWolf = new Wolf("Yellow");
• var aWolf = new Wolf("Wild", false, "Yellow");
• var aWolf = new Wolf($super, "Yellow");
• var aWolf = new Wolf(Animal, "Yellow");
24. What is the result of the following code snippet?
[1, null, 2, false, 3].partition();
Answers:
• [[1, 2, 3], [null, false]]
• [1, 2, 3, null, false]
• [1, 2, 3]
• [null, false, 1, 2, 3]
25. What is the value of b in the following code snippet?

var a = ["this", "is", "prototype"];
var b = a.inject(0, function(c, d) {
return c + d.length;
});
Answers:
• 15
• 9
• 150
• This code snippet is invalid.
26. What is the result of 10.toColorPart(); statement?
Answers:
• 0a
• 10
• 1010
• This statement causes an error.
27. Which of the following statements is valid?
Answers:
• Object.isUndefined(a);
• a.isUndefined();
• isUndefined(a);
• isDefined(a);
28. Which of the following properties holds the number of active requests?
Answers:
• Ajax.activeRequestCount
• Ajax.numberActiveRequests
• Ajax.activeRequests
• There are no such properties.
29. What is the result of the following function?

function a() {
   var x = 10;
 return x.toPaddedString(4);
}
Answers:
• 0010
• 000a
• 10.00
• This function is invalid.
30. What is the result of "this is".include("prototype"); statement?
Answers:
• this is prototype
• prototype this is
• true
• false
31. What is the result of the following code snippet?
[1, 2, 3, 4, 5].detect(function(n) {return n % 3});
Answers:
• 1
• 2
• 3
• 5
32. Consider the following code snippet:

var s = '';
(5).times(function(n) {
   s += n;
});
alert(s);
What does the alert box display?
Answers:
• 01234
• 55555
• 10
• Nothing
33. Which of the following form's functions allows you to submit a form using Ajax?
Answers:
• request
• call
• get
• post
34. What does the following statement return?
fom1.findFirstElement();
Answers:
• The first non-hidden, non-disabled control of form1 form.
• The first control of form1 form.
• The first hidden control of form1 form.
• This statement is invalid.
35. Which of the following code snippets is the proper way to define a class in prototype?
Answers:
• var Point = Class.create({initialize: function(x, y) {this.x = x; this.y = y;}});
• var Point = function(x, y) {this.x = x; this.y = y;}
• var Point = Class({Point: function(x, y) {this.x = x; this.y = y;}});
• class Point {function Point(x, y) {this.x = x; this.y = y;}};
36. The number of arguments of Try.these() are ___.
Answers:
• 2
• 4
• 6
• infinite
37. Consider the following code snippet:

Element.addMethods({
 : show: function(element) {
 : alert("This is prototype.");
  }
});

What does this code snippet do?
Answers:
• It adds show method to all elements.
• It adds show method to "element" element.
• This code snippet is invaid.
38. Which of the following functions allows/allow you to register an event to an element?
Answers:
• Event.observe
• Element.observe
• Event.register
• Element.register
39. Which of the following functions is used to call the initialize method of the parent class?
Answers:
• $super
• initialize
• Method has the same name as parent class name.
• It is not possible to call the initialize method of the parent class.
40. Which of the following methods allows you to add a new instance of method to a class after that class has been defined?
Answers:
• initialize
• constructor
• Method has the same name as class name.
• There is no constructor of prototype class.
41. If the server response time is slow, you may consider increasing the ___ option parameter to reduce the response time.
Answers:
• frequency
• wait
• interval
42. How can you stop an event from propagating?
Answers:
• Event.stop
• Event.preventDefault
• Event.stopPropagation
• Event.preventPropagation
43. 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?
Answers:
• contentType
• method
• encoding
• It is not possible to send request using xml.
44. What does identify method of element do?
Answers:
• It returns element's ID. If element does not have an ID, one is generated, assigned to element, and returned..
• It returns the id of that element.
• It generates an id for that element.
• This method does not exist.
45. Which of the following is the result of "this_is_prototype".dasherize(); statement?
Answers:
• this-is-prototype
• thisisprototype
• ThisIsPrototype
• this is prototype
46. What does cleanWhiteSpace method of element do?
Answers:
• It removes all of element's child text nodes that contain only whitespace.
• It removes whitespace from element.
• It removes whitespace from the content of all child nodes.
• This method does not exist.
47. Which of the following methods allows you to add class to a class after that class is defined?
Answers:
• Class.addMethods
• Class.includeMethods
• Class.add
• Class.include
48. The callback function in options of Ajax.Autocomplete() is called ___ the request is actually made.
Answers:
• before
• after
49. How can you add class to id1 element?
Answers:
• id1.addClass("className");
• id1.addClassName("className");
• $("id1").add("className");
• $("id1").setClassName("className");
50. Elements and ids can be interchangeable in function calls, if a function expects a document id.
Answers:
• True
• False
51. What does the following statement do?
new Ajax.Updater("el1", "/index");
Answers:
• It updates element that has "el1" id with the content response from /index page.
• It updates elements that have "el1" class with the content response from /index page.
• It updates "el1" element content with "/index" .
• This statement is invalid.
52. Which of the following functions returns the element that occurred?
Answers:
• Event.element
• Event.target
• Element.target
• Element.eventTarget
53. Which of the following is/are a valid callback of core effects?
Answers:
• beforeStart
• afterSetup
• beforeUpdate
• afterFinish
54. PeriodicalUpdater updates an element ___.
Answers:
• at the given frequency.
• with the specified number of times.
• at the given hours.
• This function does not exist.
55. Which of the following code snippets is the proper way to define a class that inherits another class?
Answers:
• var Dog = Class.create(Animal, {});
• var Dog = Class.inherit(Animal, {});
• var Dog = Class.extend(Animal, {});
• var Dog = Animal.extend({});
56. Which of the following functions updates an existing hash?
Answers:
• update
• merge
• delete
• remove
57. What does match method of element do?
Answers:
• It checks whether this element matches the given css selector.
• It checks whether this element matches the given id selector.
• It checks whether this element matches the given css or id selector.
• This method does not exist.
58. The time to complete an effect generally depends on the speed of the computer.
Answers:
• True
• False
59. $("id1").wrap("div", {"class" : "container"});
Answers:
• This code snippet will wrap id1 in a div tag.
• This code snippet will wrap div tags that have "container" class in id1 element.
• This code snippet is invalid.
60. What is the difference between the names of native browser events and prototype custom events?
Answers:
• Custom events have a colon (:) in their name.
• Native browser events have a colon (:) in their name.
• Native browser event names are case-sensitive.
• There are no differences.
61. When is the Ddom:loaded event fired?
Answers:
• Before the DOM tree is loaded.
• After the DOM tree is loaded, before window's load event.
• After load event.
• After an Ajax request finishes.
62. Which of the following element methods finds siblings of that element?
Answers:
• sibling
• adjacent
• children
• There is no such method.
63. Which of the following code snippets changes properties of element's css?
Answers:
• $('id1').morph("height: 200; width: 200;");
• $('id1').morph("height: 200", "width: 200");
• $('id1').morph("height: 200").morph( "width: 200");
• $('id1').morph({"height" =» "200", "width" =» "200");
64. ___ extends event with all of the methods contained in Event.Methods.
Answers:
• Event.extend
• Event.include
• Event.inherit
• There is no method to do so.
65. Which of the following effects are core effects?
Answers:
• Effect.Appear
• Effect.Opacity
• Effect.Tween
• Effect.Move
66. Which of the following functions converts html special characters to their entity equivalents?
Answers:
• escapeHTML
• escape
• removeHTML
• convertHTML
67. Consider the following code snippet:

1 $('id1').observe("click", function() {
2 new Effect.Highlight("id1", {startcolor: '#ff9999', endcolor: '#ffffff'});
3 return false;
4 });

If you click it once, then click it one more time while the it's highlighted, its highlighted color looks strange. Which of the following ways may fix that problem?
Answers:
• Change the second line to: new Effect.Highlight("id1", {startcolor: '#ff9999', endcolor: '#ffffff', queue: 'end'});
• Change return false; to return true;
• Change the first line to $('id1').observe("doubleclick", function() {
68. What does $F(element).getValue() return?
Answers:
• It returns the current value of a form control.
• It returns the value of function $F.
• It returns the value of any given element.
• This function is invalid.
69. What will be returned if Event.findElement("click", "div"); cannot find any elements that match the specified tag?
Answers:
• document
• null
• undefined
• The element that has registered click event handler.
70. 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?
Answers:
• This is Prototype version 1.6.1
• This is #{framework} version #{version}
• This is 1.6.1 version Prototype
• This code snippet is invalid.
71. 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?
Answers:
• id1
• InPlaceEditor
• value
• This code snippet is incorrect.
72. Function.bind(object); will replace ___ variable in function by "object".
Answers:
• this
• document
• window
• function
73. __________ allows more than one effects to occur at the same time.
Answers:
• Effect.Parallel
• Effect.Asynchronous
• Effect.run
• There is no such method.
74. What does the statement $('item1', 'item2', 'item3'); return?
Answers:
• A collection of elements with item1, item2, item3 ids.
• A collection of elements that have one of the item1, item2, item3 classes.
• This statement is invalid.
75. Which of the following methods allows you to set element attributes?
Answers:
• setAttribute
• setAttributes
• writeAttribute
• writeAttributes
76. Which of the following code snippets moves id1 element?
Answers:
• new Effect.Move("id1", {0, 0, 'relative'});
• "id1".Move("x: 0; y: 0");
• "id1".Move(x: 0, y: 0, "left");
• new Effect.Move("id1", {x: 0, y: 0});
77. The difference between Effect.SlideUp and Effect.BlindUp is that ___.
Answers:
• Effect.BlindUp hides element from the bottom first, whereas Effect.SlideUp hides element from the top first.
• Effect.SlideUp moves the element up, whereas Effect.BlindUp hides the element.
• Effect.BlindUp removes the element, whereas Effect.SlideUp hides the element.
• There is no difference.
78. Which of the following functions fires a custom event?
Answers:
• Event.fire
• Event.execute
• Event.run
• There is no such method.