カテゴリ別 2003年 | 2004年 | 2005年 | 2006年 | 2007年 | 2008年
知り合いサイト: よんだもの / 暴想 / Linuxでやる夫 / 新宿Vipper / 僕だけが幸せになればいいのに。
さらに追記:第二回試験を受けましたが、この日記の予想問題とはあんまり近くはありませんでした。試験勉強をされる方は、リファレンスマニュアルと NaCl さん謹製のRuby認定試験対策問題を読むのが良いと思います。
追記:まつもとさん曰く、実際の問題はもう少しストレートで優しいものになる予定
とのことです。
10 月に実施される予定の Ruby 技術者認定試験の問題を予想してみました。とりあえず 30 問。組み込み関数・変数・定数・クラスの問題がほとんどないので、増やすつもりです。
エントリーレベルだそうなので簡単な問題にしてみましたが、簡単すぎでしょうかね。(会社の後輩に見せたところエントリーレベルにしては難しいとの評でした。SJC-P を念頭においていたのでひねった問題にしてしまったかもしれません……)除いた分野は、ブロック、スレッド、正規表現、メタプログラミング、オブジェクト指向プログラミングです。また、処理系は CRuby 1.8.6-p36 前提です。
問題の分野の分け方や出題形式は SJC-P(Sun Certified Programmer for the Java 2 Platform)を真似しました。
念為免責文。なお、私は Ruby アソシエーションとは無関係な一個人ですので、以下の予想問題は予想問題に過ぎません。実際の試験に出る範囲や出題形式はまるで異なるかもしれません。また、この予想問題が解けたからといって実際の Ruby 技術者認定試験が解けるとは限りません。
では、以下予想問題です。
class MySite
def (A)
@url = url
end
def url
@url
end
end
site = MySite.new("http://example.org/")
puts site.url
class Exam
def self.foo
puts "a"
end
def foo
puts "b"
end
end
(A)
class Hello
puts "hello, world"
end
class Parent
end
class (A)
end
class Apple
def color
"red"
end
private :color
end
class GreenApple < Apple
def color
"green"
end
end
apple = GreenApple.new
puts apple.color
module A
def hello
puts "hello, A"
end
end
class B
def hello
puts "hello, B"
end
end
class C < B
include A
end
obj = C.new
obj.hello
class Parent
def test(text)
puts text
end
end
class Child < Parent
def test(text, number)
super
puts number
end
end
obj = Child.new
obj.test("hello", 10)
$text = "hello"
class Test
def initialize
@text = "good bye"
end
def say_hello
puts text
end
end
obj = Test.new
obj.say_hello
class MyInteger
def initialize(i)
@i = i
end
def (A)
- @i
end
end
i = MyInteger.new(10)
puts -i
if/unless/case-when
i = 0
if i
puts "true"
else
puts "false"
end
puts "foo" unless true and false || false or true
case 123
when /^\d$/
puts "digit"
when Integer
puts "integer"
when Fixnum
puts "fixnum"
else
puts "other"
end
for/while/until/each
(A)
print i
end
i = 10
while i
i = i - 1
print i
end
[1, 2, 3, 4, 5].each (A)
print i
(B)
break / retry / redo
for i in [1, 2, 3, 4, 5]
print i
if i > 3
(A)
end
end
begin-rescue-ensure
begin
array = [1, 2, 3, 4, 5]
num = array.fetch(6)
puts num
rescue ArgumentError
puts "ArgumentError"
rescue IndexError
puts "IndexError"
rescue StandardError
puts "StandardError"
end
begin
raise StandardError
rescue StandardError
exit
ensure
puts "ensure"
end
例外
begin
require "hello"
rescue
puts "hello not found"
ensure
puts "bye"
end
hello = "hello, world."
hello.chop
puts hello
def mul10(i)
i = i * 10
end
n = 10
mul10(n)
puts n
i = 1 / 3
puts i
style="color: white" してます。選択するなりテキストエリアにコピーするなりして読んでください。
最近のコメント:
RSS
![]()
This work is licensed under a
Creative Commons License
(note: text only. w/o web design, citations, (re)distributed softwares).
解答編の、A7とA11の番号と内容が、問題の選択肢のそれと食い違ってる気がします。
あ、確かに。ありがとうございます。修正しました。
19/30でした・・・。もっと勉強しないと。。