Deck 8: Object-Oriented Programming

Full screen (f)
exit full mode
Question
Encapsulation is the ability to make important object features available while hiding nonessential details, thereby focusing on the outside view of an object.
Use Space or
up arrow
down arrow
to flip the card.
Question
By default, any properties and methods that you define in a class are public , which means they can be accessed from outside the class.
Question
With inheritance, it is possible to build an entire family of classes consisting of parents, children, grandchildren and siblings.
Question
Encapsulation allows the internal representation of objects to be hidden from view outside the object definition.
Question
The problem with using global variables is that they work against object-oriented programming principles.
Question
Polymorphism can be implemented within Ruby by assigning different names to different methods.
Question
A variable with a global scope can be accessed only within the method it was created in.
Question
Abstraction is implemented through classes and includes the specification of both properties and methods.
Question
When included in a class definition, the initialize method is automatically executed any time an object is instantiated.
Question
You should assign variables the lowest level of scope needed to provide the required access.
Question
Polymorphism is the process by which one class is derived from another class.
Question
Abstraction involves the restriction of access to one or more of the properties and methods defined within a class.
Question
To use the public , private , and protected keywords, you must place them on the same line as the property or method definitions for which you wish to specify access.
Question
With inheritance, the derived class, sometimes referred to as the child class, inherits all of the properties and methods of the parent class.
Question
Access to any properties or methods that are defined after the occurrence of the public , private , and protected keywords is governed by that keyword, which remains in effect until either the end of the class is reached or a different level of encapsulation is specified.
Question
Local variables are accessible throughout a Ruby program and have an unlimited scope. Every class in the program is allowed to access them.
Question
Polymorphism is the ability to define objects and methods in different forms.
Question
Inheritance makes program code more reliable by limiting access to just the areas within the program where access is required, which helps prevent accidental modification or execution.
Question
To instantiate an object and initialize it with one or more properties in a single step you must use the initialize method.
Question
One limitation of inheritance is that you cannot modify the inherited properties and methods or add new ones to customize child classes.
Question
With ____ you can build an entire family of classes made up of parents, children, grandchildren, siblings, etc.

A) Polymorphism
B) Encapsulation
C) Abstraction
D) Inheritance
Question
____ is implemented through classes and includes the specification of both properties and methods.

A) Inheritance
B) Encapsulation
C) Abstraction
D) Polymorphism
Question
Which of the following methods can be used to instantiate and initialize and object in a single step?

A) open
B) new
C) initialize
D) init
Question
Access specified by the public, private or protected keywords, remains in affect ____.

A) Only until the statement that following it is executed.
B) Only until the methods in which it is defined is executed.
C) Until either the end of the class is reached or a different level of encapsulation is specified.
D) None of the above
Question
By creating objects based on Ruby's built-in classes, you instantly get access to all the predefined methods that Ruby defines for those objects.
Question
To control access to the properties and methods within a class, you insert the ____ keyword into the class.

A) public
B) private
C) protected
D) All of the above
Question
____ is the process by which one class is derived from another class.

A) Inheritance
B) Encapsulation
C) Abstraction
D) Polymorphism
Question
____ is the ability to define objects and methods in different forms.

A) Polymorphism
B) Encapsulation
C) Abstraction
D) Inheritance
Question
It is sometimes helpful to increase the scope of the variables to allow them to be referenced by all the methods in that class definition.
Question
The ____ keyword restricts the access of any specified properties or methods defined within the object itself.

A) public
B) private
C) protected
D) closed
Question
____ involves the restriction of access to one or more of the properties and methods defined within a class.

A) Inheritance
B) Encapsulation
C) Abstraction
D) Polymorphism
Question
A variable with a ____ scope can be accessed only within the scope that it was created in.

A) local
B) global
C) instance
D) class
Question
One way to implement ____ within Ruby is to assign the same name to different methods.

A) Encapsulation
B) Polymorphism
C) Abstraction
D) Inheritance
Question
One of the limitations of working with Ruby's built-in classes is that you can read but not modify property values.
Question
An advantage of chaining methods together is that you can perform complex tasks with a minimal amount of programming code.
Question
____ is an object-oriented feature that provides the ability to make important object features available while hiding nonessential details.

A) Abstraction
B) Encapsulation
C) Inheritance
D) Polymorphism
Question
The ____ keyword makes any specified properties or methods available throughout the program.

A) public
B) private
C) protected
D) closed
Question
The ____ keyword restricts the access of any specified properties or methods to objects of the same class or objects of subclasses of the class.

A) public
B) private
C) protected
D) closed
Question
Which of the following types of variables is supported by Ruby?

A) Local
B) Global
C) Instance
D) All of the above
Question
One limitation of working with Ruby classes is that Ruby does not permit programmer's to customize the language to meet programmer needs.
Question
Which of the following statements is a benefit of using one of Ruby's built-in classes?

A) You simplify code development by eliminating the need to re-solve already solved programming tasks
B) You instantly get access to all of the pre-defined properties in that class.
C) You instantly get access to all of the pre-defined methods in that class.
D) All of the above
Question
@occurrences is an example of a(n) ____ variable.

A) local
B) global
C) instance
D) class
Question
Class variables begin with the ____ character.

A) @
B) @@
C) $
D) _
Question
Instance variables begin with the ____ character.

A) @
B) @@
C) $
D) _
Question
____ variables are accessible throughout a Ruby program and have an unlimited scope. Every class in the program is allowed to access them.

A) Local
B) Global
C) Instance
D) Class
Question
Local variables can begin with which of the following characters?

A) @
B) @@
C) $
D) _
Question
The following statements provide an example of ____ methods together. testArray = [1, 2, 3, 4, 5] puts testArray.sort.reverse.inspect

A) linking
B) chaining
C) connecting
D) binding
Question
Which of the following lists reflects a left-to-right increase in variable scope?

A) local, global, class, instance
B) local, class, instance, global
C) local, instance, class, global
D) instance, class, local, global
Question
____ variables are similar to instance variables, except they are accessible to all the instances of the same class, which makes it easier to make repeated references to variables.

A) Local
B) Global
C) Class
D) None of the above
Question
Global variables begin with the ____ character.

A) @
B) @@
C) $
D) _
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 8: Object-Oriented Programming
1
Encapsulation is the ability to make important object features available while hiding nonessential details, thereby focusing on the outside view of an object.
False
2
By default, any properties and methods that you define in a class are public , which means they can be accessed from outside the class.
True
3
With inheritance, it is possible to build an entire family of classes consisting of parents, children, grandchildren and siblings.
True
4
Encapsulation allows the internal representation of objects to be hidden from view outside the object definition.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
The problem with using global variables is that they work against object-oriented programming principles.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
Polymorphism can be implemented within Ruby by assigning different names to different methods.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
A variable with a global scope can be accessed only within the method it was created in.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
Abstraction is implemented through classes and includes the specification of both properties and methods.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
When included in a class definition, the initialize method is automatically executed any time an object is instantiated.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
You should assign variables the lowest level of scope needed to provide the required access.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
Polymorphism is the process by which one class is derived from another class.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
Abstraction involves the restriction of access to one or more of the properties and methods defined within a class.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
To use the public , private , and protected keywords, you must place them on the same line as the property or method definitions for which you wish to specify access.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
With inheritance, the derived class, sometimes referred to as the child class, inherits all of the properties and methods of the parent class.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
Access to any properties or methods that are defined after the occurrence of the public , private , and protected keywords is governed by that keyword, which remains in effect until either the end of the class is reached or a different level of encapsulation is specified.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
Local variables are accessible throughout a Ruby program and have an unlimited scope. Every class in the program is allowed to access them.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
Polymorphism is the ability to define objects and methods in different forms.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
Inheritance makes program code more reliable by limiting access to just the areas within the program where access is required, which helps prevent accidental modification or execution.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
To instantiate an object and initialize it with one or more properties in a single step you must use the initialize method.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
One limitation of inheritance is that you cannot modify the inherited properties and methods or add new ones to customize child classes.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
With ____ you can build an entire family of classes made up of parents, children, grandchildren, siblings, etc.

A) Polymorphism
B) Encapsulation
C) Abstraction
D) Inheritance
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
____ is implemented through classes and includes the specification of both properties and methods.

A) Inheritance
B) Encapsulation
C) Abstraction
D) Polymorphism
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following methods can be used to instantiate and initialize and object in a single step?

A) open
B) new
C) initialize
D) init
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
Access specified by the public, private or protected keywords, remains in affect ____.

A) Only until the statement that following it is executed.
B) Only until the methods in which it is defined is executed.
C) Until either the end of the class is reached or a different level of encapsulation is specified.
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
By creating objects based on Ruby's built-in classes, you instantly get access to all the predefined methods that Ruby defines for those objects.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
To control access to the properties and methods within a class, you insert the ____ keyword into the class.

A) public
B) private
C) protected
D) All of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
____ is the process by which one class is derived from another class.

A) Inheritance
B) Encapsulation
C) Abstraction
D) Polymorphism
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
____ is the ability to define objects and methods in different forms.

A) Polymorphism
B) Encapsulation
C) Abstraction
D) Inheritance
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
It is sometimes helpful to increase the scope of the variables to allow them to be referenced by all the methods in that class definition.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
The ____ keyword restricts the access of any specified properties or methods defined within the object itself.

A) public
B) private
C) protected
D) closed
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
____ involves the restriction of access to one or more of the properties and methods defined within a class.

A) Inheritance
B) Encapsulation
C) Abstraction
D) Polymorphism
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
A variable with a ____ scope can be accessed only within the scope that it was created in.

A) local
B) global
C) instance
D) class
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
One way to implement ____ within Ruby is to assign the same name to different methods.

A) Encapsulation
B) Polymorphism
C) Abstraction
D) Inheritance
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
One of the limitations of working with Ruby's built-in classes is that you can read but not modify property values.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
An advantage of chaining methods together is that you can perform complex tasks with a minimal amount of programming code.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
____ is an object-oriented feature that provides the ability to make important object features available while hiding nonessential details.

A) Abstraction
B) Encapsulation
C) Inheritance
D) Polymorphism
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
The ____ keyword makes any specified properties or methods available throughout the program.

A) public
B) private
C) protected
D) closed
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
The ____ keyword restricts the access of any specified properties or methods to objects of the same class or objects of subclasses of the class.

A) public
B) private
C) protected
D) closed
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following types of variables is supported by Ruby?

A) Local
B) Global
C) Instance
D) All of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
One limitation of working with Ruby classes is that Ruby does not permit programmer's to customize the language to meet programmer needs.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
Which of the following statements is a benefit of using one of Ruby's built-in classes?

A) You simplify code development by eliminating the need to re-solve already solved programming tasks
B) You instantly get access to all of the pre-defined properties in that class.
C) You instantly get access to all of the pre-defined methods in that class.
D) All of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
@occurrences is an example of a(n) ____ variable.

A) local
B) global
C) instance
D) class
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
Class variables begin with the ____ character.

A) @
B) @@
C) $
D) _
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
Instance variables begin with the ____ character.

A) @
B) @@
C) $
D) _
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
____ variables are accessible throughout a Ruby program and have an unlimited scope. Every class in the program is allowed to access them.

A) Local
B) Global
C) Instance
D) Class
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
Local variables can begin with which of the following characters?

A) @
B) @@
C) $
D) _
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
The following statements provide an example of ____ methods together. testArray = [1, 2, 3, 4, 5] puts testArray.sort.reverse.inspect

A) linking
B) chaining
C) connecting
D) binding
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
Which of the following lists reflects a left-to-right increase in variable scope?

A) local, global, class, instance
B) local, class, instance, global
C) local, instance, class, global
D) instance, class, local, global
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
____ variables are similar to instance variables, except they are accessible to all the instances of the same class, which makes it easier to make repeated references to variables.

A) Local
B) Global
C) Class
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
Global variables begin with the ____ character.

A) @
B) @@
C) $
D) _
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.