Menu

Back Home

Rails Web Developer Quiz

Here’s a quiz we ran last year, at Employment.nil, Toronto first Ruby job fair.

See if you can get them all, I’ll post the answers in a couple weeks, and if you have your own favorite trick questions, post them here.

Javascript

1. An external JavaScript must contain the <script> tag, true or false?

2. What is the purpose of the the SWFObject javascript library?

Ruby

3. Given:

a = ‘foo’
b = nil

first = a && b
second = a and b

Are [cci]first[/cci] and [cci]second[/cci] equal?

4. True or false?
[cc lang=’ruby’]1/2 == 0.5[/cc]

5. If [cci lang=’ruby’](‘1′..’10’).to_a[/cci] returns:

[cci lang=’ruby’][“1″, “2”, “3”, “4”, ….. “10”][/cci]

What does [cci lang=’ruby’](‘2′..’10’).to_a[/cci] return?

Rails

6. Given the following class:

class Monkey << ActiveRecord::Base
has_many :bananas, :order => 'size ASC'

named_scope :starting_from_massive, :order => ‘size DESC’
end

What SQL is generated for the following queries:

[cc lang=’ruby’]

@monkey.bananas
@monkey.bananas.starting_from_massive
@monkey.bananas.all(:order => nil)

[/cc]

XHTML:

7. The DOCTYPE declaration has no closing tag, true or false?

8. All XHTML tags and attributes must be in lower case, true or false?

9. There is a way of describing XML data, how?

10. What does DTD stand for?

AJAX:

11. AJAX functionality is achieved by using what object?

CSS:

12. Should you clear floats?

13. How do you properly clear floats?

14. How do you write IE specific css?
Bonus: what is the problem with this?

Everything – Multiple Choice

15. Rails: Which of the following is not a form helper method?

a. [cci]text_field_tag[/cci]
b. [cci]text_input_tag[/cci]
c. [cci]text_area_tag[/cci]
d. [cci]hidden_field_tag[/cci]

16. What’s the default REST HTTP action verb for updating an existing record?

a. PUT
b. UPDATE
c. POST
d. PUSH

17. Which of the following is not a core Rails package?

a. ActionMailer
b. ActionController
c. ActiveRecord
d. ActiveResource

18. Which of the following is not an instance method of Object?

a. [cci]to_a[/cci]
b. [cci]to_i[/cci]
c. [cci]taint[/cci]
d. [cci]hash[/cci]

19. Which of the following is not a valid render option?

a. [cci]:update[/cci]
b. [cci]:partial[/cci]
c. [cci]:string[/cci]
d. [cci]:file[/cci]

20. Which of the following is not a valid ActionController filter declaration?

a. [cci]before_filter[/cci]
b. [cci]clear_filter[/cci]
c. [cci]after_filter[/cci]
d. [cci]around_filter[/cci]

21. Which of the following is not a valid ActiveRecord callback type?

a. [cci]before_create[/cci]
b. [cci]before_validation_on_create[/cci]
c. [cci]after_destroy[/cci]
d. [cci]before_validation_on_destroy[/cci]

22. XML is to XHTML as this is to HTML.

23. The keys of a model’s attributes are stored using this data type.

24. This is the RFC 2324 definition for HTTP status code 418.

24. Bonus: what does this do???

[cc lang=’ruby’]data.gsub(/[^\d]/, ”).split(”).reverse.enum_with_index.collect{|x, i| (i%2!=0)? (x.to_i*2).to_s.split(”).inject(0){|sum, i| sum + i.to_i} : x.to_i}.inject(0){|sum, i| sum + i}%10 != 0 [/cc]

R or RoR:
—-

1. Ruby:
Given:
a = ‘foo’
b = nil

first = a && b
second = a and b
Are first and second equal?
No. first one equals nil, second equals foo

2. Ruby:
True or false: 1/2 == 0.5
false 1/2 is int, .5 is float
1/2 is equal to zero because it is an int divided by an int, they don’t have the precision to give the correct answer

3. Ruby:
If (‘1′..’10’).to_a returns :

[“1″, “2”, “3”, “4”, ….. “10”]

what does (‘2′..’10’).to_a return?

answer: empty array because ’10’ precedes ‘2’

It’s ordering by string representation, not integer

4. Rails:

class Monkey << ActiveRecord::Base has_many :bananas, :order => ‘size ASC’

named_scope :starting_from_massive, :order => ‘size DESC’
end

What is the SQL for

@monkey.bananas
@monkey.bananas.starting_from_massive
@monkey.bananas.all(:order => nil)

Answer:
1: select * from monkeys order size ASC
2. select * from monkeys order size ASC, size DESC
3. select * from monkeys order size ASC

5. What does the H in DHH stand for? Spell it?
Hein

—-
4. XHTML:
The DOCTYPE declaration has no closing tag
False

5. All XHTML tags and attributes must be in lower case
true

6. There is a way of describing XML data, how?
Document Type Definition

7. What does DTD stand for?
Document Type Definition

Javascript:
—-
8. What is the purpose of the the swf object javascript library?
To work around the judgement against Microsoft regarding the Eolas patent defining “Embedded Objects Linked Across Systems”.

Ajax:
A little bit tougher now: AJAX functionality is achieved by using what object?
XMLHttpRequest

CSS:
—-
1.
Should you clear floats?
yes

2.
How do you properly clear floats?
overflow: hidden;
_height: 1%;

3.
How do you write ie specific css?
_element are for ie6
*element are for ie7

Bonus: what is the problem with this?

Multiple Choice

Which of the following is not a form helper method?

text_field_tag
text_input_tag
text_area_tag
hidden_field_tag

What’s the default REST HTTP action verb for updating an existing record?

PUT
UPDATE
POST
PUSH

Which of the following is not a core Rails package?

ActionMailer
ActionController
ActiveRecord
ActiveResource

Which of the following is not an instance method of Object?

to_a
to_i
taint
hash

Which of the following is not a valid render option?

:update
:partial
:string
:file

Which of the following is not a valid ActionController filter declaration?

before_filter
clear_filter
after_filter
around_filter

Which of the following is not a valid ActiveRecord callback type?

before_create
before_validation_on_create
after_destroy
before_validation_on_destroy

Simple Answers

This is the “H” in “DHH”.

What is Heinemeier?
(Spelling can count)

XML is to XHTML as this is to HTML.

What is SGML?

The keys of a model’s attributes are stored using this data type.

What is String?
or
What are Strings?

This is the RFC 2324 definition for HTTP status code 418.

What is “I’m a teapot”?
// ]]>

One Response to Rails Web Developer Quiz

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>