ruby on rails interview


 


1.A module cannot be subclassed or instantiated.

A.True 

B.False 

2.What Comes after <% form_for()...?

A. redirect_to "..."

B. the request parameters table 

C. do |f| (where 'f' can be anything)

D. <%=f.text_field:name%>    

3.Which of the following languages syntax matches with the Rubys syntax?

A.Perl 

B.PHP

C.Jquery

D.Java

4.Which sequence can be used to substitute the value of any ruby expression in a string?

A.#(expr)

B.#{expr}

C.#expr

D.none of the above 

5.When you put something into an array,does the array keep a separate copy?

A.no.arrays just keep references to objects stored in memory.

B.the data being presented by the web page 

C.it is not associated with a model 

D.the request paramters table

6.Which of the following is not a valid library function?

A.Puts 

B.Print 

C.Gets

D.Get

7.What's the difference between model name and controller names?

A.the method within the controller to call 

B.the data being presented by the webpage 

C.model names are singular,controller(and table) names are plural

D.in the controller:respond_to do |format| ...end 

8.what steps get you from file.erb to file.html?

A. data from model objects AND the page template 

B. erb -> Embedded Ruby -> ruby code(file.rb) -> file.html

C. the method within the controller to call 

D. the data being presented by the web page 

9.what is the filter code that calls on the "check_logged_in" method for only the "edit" and "update" methods?

A.the data being presented by the web page 

B.HTTP methods(post,get,put,delete)

C.data from model objects AND the page template 

D.before_filter:check_logged_in, :only =>[:edit,:update]

10.What is the output of the following? I am learning ruby language.length 

A. 27 

B. 23 

C. 26

D. 18

11.Convert database records to objects is called ________.

A. for ad in @ads 

B. integration test 

C. Representational State Transfer 

D. an object-relational mapping library 

12.where do you add the filter code?

A. rails generate migration AddPhoneToTickets phone:string

B. the data being presented by the web page 

C. data from model objects AND the page template 

D. right after the line introductitng the class in the controller 

13.what environments does Rails have by default?

A. development,test,production 

B. render:partial 

C. RAILS_ENV(RAILS_ENV=production)

D. integration test 

14.how do you generate regular model code (not scaffolding)?

A. just replace the word "scaffold" with the word "model"

B. it is not associated with a model 

C. username=="admin" && password=="some_password"

D. do |f| (where "f" can be anything)

15.What will be the output of the following?Ruby.reverse.upcase 

A. RUBY 

B. ybuR

C. YBUR

D. YBUr

16.how do you tie an action to that only kicks in for the edit,update,and destroy methods?

A.index,show,new,edit,create,update,destroy

B. code=tweet; :method => :delete url=/tweets/1 

C.before_filter:get_tweet,:only=>[:edit,:update,:destroy]

D.@tweet=Tweet.create(:status=>params[:tweet][:status])

17.What is the output of the given code? "Ruby".length #to find the length of given string 

A.4 to find the length of given string 

B.4 

C.To find the length of given string

D.Ruby

18.How do you define a "status" parameter(within a "tweet" parameter)?

A.code=tweet,url=/tweets/1

B.@tweet=Tweet.create(:status=>params[:status])

C.params = {:tweet =>{:status=> "I' m dead"}}

D.@tweet=Tweet.create(:status => params[:tweet][:status])

19.What does %Q{Learn ruby language} represents?

A."Learn Ruby language"

B."%{Learn Ruby language}"

C."Learn Ruby language"

D.none of the mentioned

20.When Whitespace characters such as spaces and tabs can not ignored in Ruby code?

A. While using strings

B. While using integer

C. while using float value

D. All of the above

21.Which character is used to give comment in ruby?

A. !

B. @

C. #

D. $

22.Which of the following are valid floating point literal?

A. 0.5

B. 5

C. 0.5

D. 5

23.Which of the following is not a Reserved Words in Ruby?

A. begin

B. ensure

C. retry

D. pass

24.Block comment conceals several lines from the interpreter with?

A. =begin and =end

B. =start and =end

C. =here and =end

D. =begin and =ending

25.Which of the following features does the 2.0 version of ruby supports?

A. New literals

B. Security fixes

C. Method keyword arguments

D. All of the above

26.Ruby 2.7.1 version release date?

A. 31-03-2019

B. 31-01-2020

C. 31-03-2020

D. 31-04-2019

27.Which statement is used to declares code to be called before the program is run?

A. Start

B. Begin

C. Here

D. End

28.Ruby was written in?

A. C

B. C++

C. Java

D. Objective C

29.what environments does Rails have by default?

A.development, test, production

B.render :partial

C.RAILS_ENV (RAILS_ENV=production)

D.integration test

30.how do you generate regular model code (not scaffolding)?

A.just replace the word "scaffold" with the word "model"

B.it is not associated with a model

C.username == "admin" && password == "some_password"

D.do |f| (where "f" can be anything)

31.what does Embedded Ruby (ERb) process as inputs?

A.data from model objects AND the page template

B.HTTP methods (post, get, put, delete)

C.it is not associated with a model

D.their names begin with an underscore

32.what is "format" in "repond_to do |format|"?

A.underscores

B.an object

C.a responder object

D.integration test

33.how do you add an error (called "there was an error") in the validate method?

A.redirect_to " ... "

B.errors.add_to_base("there was an error")

C.the word "private"

D.their names begin with an underscore

34.if the table Seats is associated with the table Flights, how should you name the table column in Seats to indicate its flight?

A.an object

B.flight_id

C.ruby make

D.#{1+1}

35.what method name indicates to rails that it should validate before saving/updating?

A.validate

B.ActionPack

C.flight_id

D.ruby make

36.When is it best to use an array rather than a hash?

A.An array uses indices and a hash uses "keys"

B.puts (pronounced "put-ess")

C.Red refers to writing a failing test

D. When the order matters, use an array.

37.What is the main benefit that a Class gets by inheritance from ApplicationController?

A.An array uses indices and a hash uses "keys"

B. When a request is made for, say, /pages/home, the Pages controller executes the code in the "home" action and then automatically renders the view corresponding to the action -- in this case, home.html.erb.

C.This maps requests for the URL /pages/home to the home action in the Pages controller.

D.When the order matters, use an array.

38.how do you define a "status" parameter (within a "tweet" parameter)?

A.code = tweet,url = /tweets/1

B.@tweet = Tweet.create(:status =>params[:status])

C.params = {:tweet => {:status => "I'm dead" }}

D. @tweet = Tweet.create(:status =>params[:tweet][:status])

39.how do you tie an action to that that only kicks in for the edit, update, and destroy methods?

A. index, show, new, edit, create, update, destroy

B.code = tweet, :method => :delete url = /tweets/1

C.before_filter :get_tweet, :only => [:edit, :update, :destroy]

D.@tweet = Tweet.create(:status =>params[:tweet][:status])

40.what do you use to send messages to the user?

A. t.errors

B.:status

C. a flash

D.@tweet

41.Objects of which class does the integer from the range -2^30 to 2^(30-1) belong to ?

A. Fixnum 

B. Binary 

C. Bignum 

D. Octal

42.Block comment conceals several lines from the interpreter with ?

A. =start and =end 

B. =begin and =ending 

C. =here and =end 

D. =begin and =end 

43.what should you write in routes.rb to give meaning to http://mebay.com/ads/3?

A. from general to specific ('/ads/' and then '/ads/:id')

B. map.connect '/ads/:id', :controller=>'ads', :action=>'show'

C. include test.xml to root of "public" folder and ,render (:partial=>'map', :locals=>{:data=>'/test.xml'})

D. form_for(@object, :url=>{:action=>'create'})

44.how does Rails choose to correct format to generate?

A. in the controller: respond_to do |format| ... end

B. it is not associated with a model

C. redirect_to " ... "

D. the data being presented by the web page

45.why do you only need to call "render" in the controller sometimes and not always?

A. .:format (that period is a concatenation period)

B. redirect_to " ... "

C. errors.add_to_base("there was an error")

D. if you're happy with the default template, you can omit "render"

46.aRESTful application uses ... to define an interaction with the data.

A. a responder object

B. it is not associated with a model

C. HTTP methods (post, get, put, delete)

D.the request parameters table

47.what does a model object do before it saves or updates data?

A. underscores

B. it runs its validators

C. validate

D.rake db:migrate

48.what method name indicates to rails that it should validate before saving/updating?

A. validate

B. ActionPack

C. flight_id

D. ruby make

49.When is it best to use an array rather than a hash?

A. An array uses indices and a hash uses "keys"

B. puts (pronounced "put-ess")

C. Red refers to writing a failing test

D. When the order matters, use an array.

50.to add login security, which two pieces of code do you need?

A.1.all important data is a resource2. every resource has a proper name (URL)

B..:format (that period is a concatenation period)

C.the method within the controller to call

D.1. login method (that checks a username and password) and 2. a filter (that calls the login method when needed)

I am having internship experience of 6 month in Django Rest Framework . I have a good foundation of knowledge of all the required subjects. Though I may be a fresher, I am a very quick learner and also I am highly trainable.I am Passionate About Machine Learning and AI.I have ability to lead the team.One of my skill is googling

Question noAnswer
1A
2C
3A
4B
5A
6D
7C
8B
9D
10A
11D
12D
13A
14A
15C
16C
17B
18D
19A
20A
21C
22A
23D
24A
25D
26C
27B
28A
29A
30A
31A
32C
33B
34B
35A
36D
37B
38D
39C
40C
41A
42D
43B
44A
45D
46C
47B
48A
49D
50D

Post a Comment

Previous Post Next Post