Deck 9: File and Folder Administration

Full screen (f)
exit full mode
Question
By default, a computer receives standard input ( STDIN ) from the keyboard
Use Space or
up arrow
down arrow
to flip the card.
Question
Ruby allows you to delete both files and folders using the File and Dir classes's delete methods.
Question
When executed on Microsoft Windows, Ruby program file and path data must be specified using the backslash character.
Question
By default, a computer sends standard output ( STDOUT ) to the computer's hard drive.
Question
Ruby lists the contents of a folder using the Dir class's files method.
Question
Ruby allows you to create new folders using the Dir class's creatdir method.
Question
Using the File class's folder? method, you can determine if a resource is a folder or something else (socket, pipe, etc.).
Question
If you attempt to delete a file or folder that does not exist, or if you try to delete a folder that is not empty, Ruby will ignore the error and substitute an empty file.
Question
Ruby allows you to rename a file using the File class's rename method.
Question
To determine if a file or folder exists, use the File class's exist? method.
Question
The File class gives you access to various file administration methods.
Question
The File class also contains a method named file? , which can be used to determine whether a resource is a file or something else.
Question
The Dir class's entries method returns the contents of the folder as an array.
Question
One limitation within Ruby programming is the inability to redirect STDIN and STDOUT .
Question
The Folder class gives you access to various folder administration methods.
Question
The operating system, and not Ruby, provides both the > and the redirection operators.
Question
Given a script named DispMsg.rb, if an empty file were used as input to: ruby DispMsg.rb a value of nil would be assigned to the message variable in the statement: message = STDIN.gets
Question
The movement of data from one place to another is referred to as data input and data output.
Question
The Dir class's size method returns a count of the specified file's size in bytes.
Question
To determine if a file has any data in it, you can use the File class's size method.
Question
To determine if a file or folder exists, use the File class's ____ method.

A) file?
B) value
C) exist?
D) found?
Question
Which of the following File class methods can be used to determine if a file or folder exists?

A) location?
B) found?
C) exist?
D) file?
Question
Which of the mode options opens a file for writing only, overwriting any existing text by placing the pointer at the beginning of the file.

A) w
B) w+
C) a
D) a+
Question
If an empty file were used as input to the operator, a ____ value is returned.

A) empty string
B) nil
C) zero
D) null
Question
Which of the following Dir class methods can be used to create a new folder?

A) mkdir
B) createdir
C) mk
D) create
Question
Which of the following characters can be used as a shortcut for representing resources stored within the current working directory?

A) _
B) -
C) .
D) @
Question
RUBY_PLATFORM contains a string that identifies the type of operating system on which a script is executing.
Question
Which of the following File class methods can be used to determine if a file has any data in it?

A) length
B) size?
C) name?
D) size
Question
Which of the mode options opens a file for reading only?

A) r
B) r+
C) a
D) a+
Question
Which of the following is the Ruby redirection output operator?

A) =
B) =>
C) >
D) ^
Question
Which of the mode options opens a file for both reading and writing, overwriting any existing text. If the specified file does not exist, it is created.

A) w
B) w+
C) a
D) a+
Question
If you develop a script that will run on different operating systems, you will need a way to determine which type of operating system your script is currently executing on. One way to do this is by taking advantage of Ruby's RUBY_PLATFORM special variable.
Question
RUBY_PLATFORM contains a string that identifies the manufacturer of the operating system on which a script is executing.
Question
Which of the following File class methods can be used to determine if a resource is a folder or something else?

A) directory?
B) file?
C) found?
D) type?
Question
Which of the mode options opens a file for both reading and writing?

A) r
B) r+
C) a
D) a+
Question
When executed on UNIX or Linux, Ruby program file and path data must be specified using the backslash character.
Question
A special variable is a specially named variable that once you have defined it, is automatically updated by Ruby during program execution.
Question
Which of the following File and Dir methods can be used to delete both files and folders?

A) remove
B) delete
C) kill
D) del
Question
Which of the following File class methods can be used to determine if a resource is a file or something else?

A) directory?
B) file?
C) found?
D) type?
Question
Which of the following Dir class methods can be used to return a list of the contents of a folder in the form of an array.

A) list?
B) entries
C) collection
D) content
Question
Which of the following File class methods can be used to change a file's name?

A) change
B) update
C) modify
D) rename
Question
Which of the mode options opens a file in append mode, allowing for both reading and writing while preserving any preexisting text.

A) w
B) w+
C) a
D) a+
Question
A reference can be set up for a file using which of the following File methods?

A) new
B) existing
C) open
D) file
Question
What type of variable is the RUBY_PLATFORM special variable?

A) integer
B) float
C) bignum
D) string
Question
Which of the following best describes a special variable?

A) It is a variable specified by the programmers and maintained by Ruby.
B) It is a variable automatically created by Ruby but for which the programmer must assign an initial value.
C) It is a variable that is automatically created and maintained by Ruby.
D) It is a variable that is automatically created by Ruby for its use only.
Question
Which of the following methods can be used to open a file for reading?

A) new
B) access
C) open
D) process
Question
Which of the following is a special variable containing a string that identifies the type of operating system on which a script is executed?

A) RUBY_SYSTEM
B) RUBY_PLATFORM
C) RUBY_OSTYPE
D) RUBY_TYPE
Question
Which of the mode options opens a file in append mode, preserving any preexisting text while allowing new text to be added to the end of the file.

A) w
B) w+
C) a
D) a+
Question
Which of the following actions occur if you attempt to delete a file or folder that does not exist?

A) Ruby ignores the error and allows the program to continue
B) Ruby deletes any files found in the current working directory
C) An error is generated and program execution terminates
D) None of the above
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/49
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 9: File and Folder Administration
1
By default, a computer receives standard input ( STDIN ) from the keyboard
True
2
Ruby allows you to delete both files and folders using the File and Dir classes's delete methods.
True
3
When executed on Microsoft Windows, Ruby program file and path data must be specified using the backslash character.
True
4
By default, a computer sends standard output ( STDOUT ) to the computer's hard drive.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
5
Ruby lists the contents of a folder using the Dir class's files method.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
6
Ruby allows you to create new folders using the Dir class's creatdir method.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
7
Using the File class's folder? method, you can determine if a resource is a folder or something else (socket, pipe, etc.).
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
8
If you attempt to delete a file or folder that does not exist, or if you try to delete a folder that is not empty, Ruby will ignore the error and substitute an empty file.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
9
Ruby allows you to rename a file using the File class's rename method.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
10
To determine if a file or folder exists, use the File class's exist? method.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
11
The File class gives you access to various file administration methods.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
12
The File class also contains a method named file? , which can be used to determine whether a resource is a file or something else.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
13
The Dir class's entries method returns the contents of the folder as an array.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
14
One limitation within Ruby programming is the inability to redirect STDIN and STDOUT .
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
15
The Folder class gives you access to various folder administration methods.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
16
The operating system, and not Ruby, provides both the > and the redirection operators.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
17
Given a script named DispMsg.rb, if an empty file were used as input to: ruby DispMsg.rb a value of nil would be assigned to the message variable in the statement: message = STDIN.gets
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
18
The movement of data from one place to another is referred to as data input and data output.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
19
The Dir class's size method returns a count of the specified file's size in bytes.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
20
To determine if a file has any data in it, you can use the File class's size method.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
21
To determine if a file or folder exists, use the File class's ____ method.

A) file?
B) value
C) exist?
D) found?
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
22
Which of the following File class methods can be used to determine if a file or folder exists?

A) location?
B) found?
C) exist?
D) file?
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the mode options opens a file for writing only, overwriting any existing text by placing the pointer at the beginning of the file.

A) w
B) w+
C) a
D) a+
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
24
If an empty file were used as input to the operator, a ____ value is returned.

A) empty string
B) nil
C) zero
D) null
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following Dir class methods can be used to create a new folder?

A) mkdir
B) createdir
C) mk
D) create
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
26
Which of the following characters can be used as a shortcut for representing resources stored within the current working directory?

A) _
B) -
C) .
D) @
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
27
RUBY_PLATFORM contains a string that identifies the type of operating system on which a script is executing.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
28
Which of the following File class methods can be used to determine if a file has any data in it?

A) length
B) size?
C) name?
D) size
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the mode options opens a file for reading only?

A) r
B) r+
C) a
D) a+
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following is the Ruby redirection output operator?

A) =
B) =>
C) >
D) ^
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the mode options opens a file for both reading and writing, overwriting any existing text. If the specified file does not exist, it is created.

A) w
B) w+
C) a
D) a+
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
32
If you develop a script that will run on different operating systems, you will need a way to determine which type of operating system your script is currently executing on. One way to do this is by taking advantage of Ruby's RUBY_PLATFORM special variable.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
33
RUBY_PLATFORM contains a string that identifies the manufacturer of the operating system on which a script is executing.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
34
Which of the following File class methods can be used to determine if a resource is a folder or something else?

A) directory?
B) file?
C) found?
D) type?
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
35
Which of the mode options opens a file for both reading and writing?

A) r
B) r+
C) a
D) a+
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
36
When executed on UNIX or Linux, Ruby program file and path data must be specified using the backslash character.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
37
A special variable is a specially named variable that once you have defined it, is automatically updated by Ruby during program execution.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
38
Which of the following File and Dir methods can be used to delete both files and folders?

A) remove
B) delete
C) kill
D) del
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following File class methods can be used to determine if a resource is a file or something else?

A) directory?
B) file?
C) found?
D) type?
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
40
Which of the following Dir class methods can be used to return a list of the contents of a folder in the form of an array.

A) list?
B) entries
C) collection
D) content
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
41
Which of the following File class methods can be used to change a file's name?

A) change
B) update
C) modify
D) rename
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
42
Which of the mode options opens a file in append mode, allowing for both reading and writing while preserving any preexisting text.

A) w
B) w+
C) a
D) a+
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
43
A reference can be set up for a file using which of the following File methods?

A) new
B) existing
C) open
D) file
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
44
What type of variable is the RUBY_PLATFORM special variable?

A) integer
B) float
C) bignum
D) string
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
45
Which of the following best describes a special variable?

A) It is a variable specified by the programmers and maintained by Ruby.
B) It is a variable automatically created by Ruby but for which the programmer must assign an initial value.
C) It is a variable that is automatically created and maintained by Ruby.
D) It is a variable that is automatically created by Ruby for its use only.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
46
Which of the following methods can be used to open a file for reading?

A) new
B) access
C) open
D) process
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
47
Which of the following is a special variable containing a string that identifies the type of operating system on which a script is executed?

A) RUBY_SYSTEM
B) RUBY_PLATFORM
C) RUBY_OSTYPE
D) RUBY_TYPE
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
48
Which of the mode options opens a file in append mode, preserving any preexisting text while allowing new text to be added to the end of the file.

A) w
B) w+
C) a
D) a+
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
49
Which of the following actions occur if you attempt to delete a file or folder that does not exist?

A) Ruby ignores the error and allows the program to continue
B) Ruby deletes any files found in the current working directory
C) An error is generated and program execution terminates
D) None of the above
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 49 flashcards in this deck.