- Which of the following is NOT required in an XHTML file?
- An XHTML validation header.
- Attribute values must be in double quotes.
- Tag names must be spelled in upper case.
- Tags must be nested.
- What is a CSS class?
- The set of images in /public/images.
- The set of input tags in the view.
- The set of HTML tags in the body section of the page.
- A user defined set of properties and values that can be used to set the style for HTML
elements.
- Which of the following is NOT a server-side programming language?
a. ASP.Net b. JavaScript c. PHP d. Ruby on Rails
- What is a controller?
a. A collection of Ruby script files. b. A DOS command.
c. An HTTP routing destination. d. A Ruby class containing one method for each action.
- What does this command line statement do?
- Creates a complete HTML file from a view file.
- Implements the specifications generated by the previous migrate statement.
- Removes all improper scripts in a project.
- Updates the timestamps for all database rows.
- What does this Ruby statement do?
- Gives the index view (if one exists) priority over the current view.
- Places the proper view code within a layout.
- Stops the execution of the current controller.
- Switches to a different controller.
- Which of these is NOT an HTTP command?
a. DELETE b. GET c. LIST d. POST
- What is the default port for HTTP?
a. 80 b. 1023
c. 3000 d. 5000
- What is a resource?
- A database table that is created by the controller.
- A piece of information that is accessed or otherwise processed by a Rails project.
- Images that are stored in the public folder.
- Text that is displayed on the views.
- If these Ruby statements are executed today (October 12, 2010), what is the output?
a = Time.now
b = a.mon
c = a.day
puts c + " " + b
a. 10 12 b. 12 10 c. 1012 d. 1210
- Which Ruby statement randomly assigns n to 10 or 20 with equal probability?
a. n = 10 + rand(20) b. n = 10 + 10 * rand(2)
c. n = 10 * (1 + rand(1)) d. n = 10 * (1 + rand(21))
- What is the meaning of = in Ruby?
- Assigns the value of an expression to a variable.
- Checks whether two objects are equal.
- Used to evaluate a method in the controller.
- Used to solve a mathematical equation.
- What are the possible return values from the <=> operator method:
a. true or false
b. true, false, or nil
c. 0 or 1
d. -1, 0, or 1
- Write a Ruby script that inputs the course score and outputs the
course grade.
A == 90..100, B == 80..89, C == 70..79, D == 60..69,
F == 0..59.
Use an if..elsif..end statement. Ans:
- What is the output?
t = Time.now
if t.mon == 11
@s = "Current month is November."
else
@s = "Current month is not November."
end
- What is the output
x = 348
s = 'xyz'
print x, s
print "#{x + 2}\n#{'abc' + s}"
- What is the output?
x = 5
if x + 2 > 9
a = "yes"
else
a = "no"
end
print a, "\n"
- Modify the Chinese Zodiac Example (Example ??) to
accept user input.
- Rewrite the Consultant BS Generator Example (Example 18) to display the
output on a web page.
- Add this method to the Dice class
(Example 14) and test it:
def doubles?
if @die1 == @die2
return true
else
return false
end
end
- Write lines of Ruby code to test this Person class:
class Person
def initialize(the_name, the_age)
@name = the_name
@age = the_age
end
def display
print "Name: #{@name} Age: #{@age}\n"
end
def have_birthday
@age = @age + 1
end
end
- Draw the UML diagram of the Person class in Problem 23.