1. A(n) ________ is a named Emacs object that
represents something editable, usually a file in your filesystem, but also the
Clojure REPL or debugger, for example.
Answers:
• Buffer
• paredit
• inferior-lisp
• Window
2. Refs _____
Answers:
• provide
thread-local variable bindings
• manage
independent, synchronous changes to a single location
• provide thread-isolated transactions
• manage
independent, asynchronous changes to a single location
3. Vars _____
Answers:
• provide thread-local variable bindings
• manage
independent, synchronous changes to a single location
• provide
thread-isolated transactions
• manage
independent, asynchronous changes to a single location
4. A function can be stored in a var or passed as an
argument to other functions.
Answers:
• True
• False
5. True or False? Sets are collections of unique
items. They are better than lists and vectors when duplicates aren't allowed.
Answers:
• False
• True
6. True or False? The Clojure language is
homoiconic.
Answers:
• True
• False
7. lib-noir, Ring, and Compojure are all examples of Clojure:
Answers:
• JSON service
modules
• SOAP service
modules
• HTTP service modules
• API service
modules
• REST service
modules
8. STM stands for _____
Answers:
• Step, Translate,
Motion
• Safe
Transactions in Memory
• State Transfer
Machine
• Software Transactional Memory
9. Stack abstraction is supported in Clojure via what three operations?
Answers:
• get, find, pop
• find, conj, get
• get, nth, find
• conj, pop, peek
10. A multimethod is created using a ________form, and implementations of a multimethod are provided by ___________ form.
Answers:
• defmulti, defmethod
• derive,
make-heiracrchy
• fill,
fill-dispatch
• defmethod,
defmulti
11. Locks _____
Answers:
• provide
thread-isolated transactions
• are a low-level construct that should be avoided in most
cases
• manage
independent, asynchronous changes to a single location
• provide
thread-local variable bindings
12. let is a _____
Answers:
• Reserved Keyword
• Macro
• Function
• Special Form
13. A Clojure sequence is a Java
Answers:
• Iterable
• Map
• Iterator
• List
14. True or False? Clojure is NOT an imperative language.
Answers:
• True
• False
15. In many object-oriented languages, ________________ is a way to decouple a class from other objects upon which that class depends.
Answers:
• chain of
responsibility
• the template
method
• dependency injection
• strategy pattern
16. True or False? Metadata is data about data, and has no effect on the 'host' data.
Answers:
• False
• True
17. True or False? Clojure a functional language.
Answers:
• True
• False
18. What is the syntax of the "if" function?
Answers:
• (if condition then-expr else-expr)
• (condition
to-expr else-expr)
• (condition if
then-expr else-expr)
•
(condition-if-then-expr-else expr)
19. Which is an example of a Clojure function call?
Answers:
• (function-name arg1 arg2 arg3)
• (method-name
arg1 arg2 arg3)
• function-name
(arg1, arg2, arg3)
• methodName(arg1,
arg2, arg3)
20. What is significant about function names that end with a "!"?
Answers:
• It warns users
that the function is deprecated.
• It serves as a
warning that the function in question may produce an unstable result.
• It is a convention that indicates the function mutates some
state.
• All functions
that mutate some state must end with a "!", or else you will get a
compiler error.
21. In Clojure, you can create a new class using _____
Answers:
• All of the above
• gen-class
• proxy
• deftype
22. Clojure strings are Java Strings and are represented in exactly the same way, delimited by double quotes.
Answers:
• True
• FALSE
23. Which is a type of collection in Clojure?
Answers:
• None of these
• Set
• Vector
• All of these
24. Which statement best describes protocols in Clojure?
Answers:
• A protocol
defines how two programs communicate over a computer network.
• Clojure provides
several macros that make it easy to implement various network protocols.
• A protocol defines an interface. But unlike Java interfaces,
which must be specified when a class is created, protocols can be attached to a
class at any time.
• Clojure uses the
term "protocol" to refer to what Java calls an "interface".
25. What is the function that evaluates a single argument form?
Answers:
• eval
• test
• defn
• var
26. True or False? Arity is the number of arguments a function can handle.
Answers:
• True
• False
27. Leiningen uses _____ to locate and manage project dependencies
Answers:
• Ivy
• GitHub
• SourceForge
• Maven
28. What does the REPL tool do?
Answers:
• Read-eval-print loop
• Read-enter-print
look
• Repeat-eval-pair
loop
• Read-eval-part
loop
29. Which of the following code fragments evaluates to 5?
Answers:
• ({:a 1 :b 3 :c
5} :c)
• All of the above
• (get {:a 1 :b 3
:c 5} :c)
• (:c {:a 1 :b 3
:c 5})
30. Clojure is hosted on the JVM (Java Virtual Machine) and can use any Java library.
Answers:
• FALSE
• True
31. True or False? In Clojure a symbol can contain characters that most imperative languages don't allow in variable names. (Example: in Clojure you can have a symbol with the name +a-.)
Answers:
• False
• True
32. What does the "contains?" function work on?
Answers:
• All of these
• Vectors
• Maps
• Sets
33. Does Clojure have a metadata system that allows for annotation of symbols and collections?
Answers:
• True
• False
34. True or False? Clojure programs only support some Java classes and interfaces.
Answers:
• False
• True
35. To calculate the average of some numbers in Clojure, your code would look like this:
Answers:
• def average
(numbers): return sum( numbers) / len( numbers)
• (defn average [numbers] (/ (apply + numbers) (count
numbers)))
• def average
(numbers) numbers.inject(: +) / numbers.length end
• public static
double average (double[] numbers) { double sum = 0; for (int i = 0; i <
numbers.length; i + +) { sum + = numbers[ i]; } return sum / numbers.length; }
36. Collections that classically support last-in, first-out (LIFO) semantics are called ____________.
Answers:
• vectors
• contains
• indices
• stacks
37. What type does the following code result in? {:a 1 "b" 2}
Answers:
• Array
• Vector
• Map
• List
38. Which statement about Clojure macros is true?
Answers:
• Macros provide
an ad-hoc mechanism for improving the performance of critical code.
• Macros are
basically a glorified parameterizable search-replace mechanism. They are error
prone, and should be avoided at all costs.
• Macros allow programmers to specify program transformations
that occur during compile time.
• Macros are
useful, but Clojure's implementation of them is very limited.
39. The reduce function is used to _____
Answers:
• aggregate the elements in a collection using a given
function and return the result as a single value
• All of the above
• apply a function
to all elements in a collection and return a sequence of the results
• substract a
given amount from an integer value
40. How do you create an anonymous function?
Answers:
• prefix#
•
#(double-expression)
• #(single-expression)
• #{items}
41. :foo is an example of a(n) _____
Answers:
• keyword
• variable name
• symbol
• atom
42. How do you add metadata to a symbol or collection?
Answers:
• (class-name.
args)
•
{key-value-pairs}
•
#"pattern"
• ^{key-value-pairs} object
43. What are sequences?
Answers:
• Ordered codes
• Specific
collections
• Concrete lists
• Logical views of collections
44. What do keywords begin with?
Answers:
• :
• -
• #
• ;
45. The following code will evaluate to true? (defn +++ [n] (+ (inc n) 1)) (= (+++ 1) 3)
Answers:
• True
• Can't define a
reserved symbol
• + is reserved
and can't be re-defined
• Syntax error
• False
46. The two comment types that are defined by the reader are:
Answers:
• textual comments
and multi-line comments
• custom comments
and code-snippets
• basic comments
and source comments
• Single-line comments and Form-level comments
47. If you are already using Java or another JVM language for RDBMS work, it’s likely that you’re using ______________, easily the most popular Java object/ relational mapping library.
Answers:
• Hibernate
• SLIME
• Korma
• Entity
48. A built-in Clojure "operation" may be implemented as a...
Answers:
• Function
• All of these
• Special Form
• Macro
49. What are the 3 phases Clojure code is processed in?
Answers:
• Read-time, compile-time, run-time
• Read-time,
compile-time, load-time
• Read-time,
gather-time, run-time
• There are
actually 4 phases.
50. Clojure provides several "persistent" data structures. Objects of these classes are _____
Answers:
• serializable
• stored in a
database
• immutable
• implemented in a
way that makes them robust in case of memory errors
51. Clojure is primarily an imperative language.
Answers:
• False
• True
52. How would you want to create a new Atom with an initial value <value>?
Answers:
• (make-atom
<value)
• (new 'Atom
<value>)
• (new-atom value)
• (new Atom
<value>)
• (atom <value>)
53. What type does the following code result in? [1 2 3 4]
Answers:
• List
• Map
• Vector
• Array
54. What is the literal syntax for maps?
Answers:
• {:a 1 :b 2}
• #{:a 1 :b 2}
• [:a 1 :b 2]
55. True or False? A lazy-sequence can hold all the possible calculations of the Fibonacci sequence.
Answers:
• False
• True
56. We can use _____________ to create a table with a specific name and define columns.
Answers:
• with-connection
• with-query-results
• transaction
• create-table
57. What is generally the first step in deploying your Clojure web application?
Answers:
• Installing and configuring Leiningen or setting up and
configuring an app server.
• Copying the .war
file your build process is producing to your server.
• Restarting the
application
• Reverting your
application's .war file to a prior version.
58. What is the conventional first and last character used to name vars intended to be bound to new, thread-local values?
Answers:
• (
• *
• "
• ^
59. What's a difference between quote (') and syntax-quote (`) macro characters?
Answers:
• Quote (') fully
qualifies symbols, while syntax-quote (`) doesn't
• Syntax-quote (`) fully qualifies symbols, while quote (')
doesn't
• There is no
difference between quote (') and syntax-quote (`)
60. (= (map + '(1 2 3)) 3)
Answers:
• True
• False
• (1 2 3)
• 6
• 5
61. True or False? Function definitions must appear before they're first used.
Answers:
• True
• False
62. Which statement regarding Clojure "forms" is true?
Answers:
• Every form is a
function call, but not every function call is a form.
• Every function call is a form, but not every form is a
function call.
• The terms
"function call" and "form" are completely interchangeable.
• A form is like a
function call, except it invokes a macro instead.
63. ________ is a very low-level looping and recursion operation that is usually not necessary.
Answers:
• reduce
• recur
• map
• leap
64. In Clojure >= 1.3, which of these follows the naming conventions for dynamic objects? (def ^:dynamic *d* (atom [])) (def ^:dynamic d (atom []))
Answers:
• *d*, but not d
• d, but not *d*
65. To represent a boxed decimal in Clojure, you would use ____________.
Answers:
• Float
• float
• Fixnum
• java.lang.Double
66. To represent a boxed decimal in Clojure, you would use ____________.
Answers:
• Float
• float
• Fixnum
• java.lang.Double
67. In Clojure, tail-call optimization is _____
Answers:
• done for every
call which is in a tail position
• only done for
simple recursion
• not supported natively by the compiler, but could be
simulated using thunks, trampolines, and macros.
• impossible
68. You can use ___________ whenever you like if you need a unique symbol, but its primary role is in helping us write hygienic macros.
Answers:
• defmacro
• hygienic
• important-value
• gensym
69. Suppose you want to implement a set of mutually-recursive functions. Which approach might you take?
Answers:
• Define the functions using letfn
• Define the
functions locally using def
• Define the
functions using let
• Since Clojure
only supports simple recursion, you need to convert to an iterative algorithm.
70. True or False? (reset!) is used to set the value of an atom.
Answers:
• False
• True
71. What provides synchronous changes to a single piece of shared data?
Answers:
• Vars
• Agents
• Refs
• Atoms
72. What provides synchronous changes to a single, thread-local value?
Answers:
• Atoms
• Refs
• Agents
• Var
73. True or False? In functional oriented languages, you can't manipulate objects like in object oriented languages.
Answers:
• True
• False
74. If you want to create class that extends another class, you must use _____
Answers:
• deftype
• gen-class
• reify
• defrecord
75. The application of advice or other aspect transformations is often called __________.
Answers:
• wrapping
• weaving
• advising
• profiling
76. A "dynamic" var _____
Answers:
• has a value that
is shared across multiple threads
• has a value that is related to the call stack, and can be
used to pass contextual information between functions that do not call each
other directly
• must be expected
to change value at any time, even if there is no local code that changes it
• is a variable
that has mutable state
77. Atoms _____
Answers:
• manage independent, synchronous changes to a single location
• manage
independent, asynchronous changes to a single location
• provide
thread-isolated transactions
• provide
thread-local variable bindings
78. A _______ is a construct that suspends some body of code, evaluating it upon demand, when it is "deref"erenced.
Answers:
• deliver
• promise
• future
• delay
79. What is the Closure equivalent to ClassName.class in Java?
Answers:
• Class.name
•
(ClassName.class)
• ClassName.CLASS
• ClassName
80. What's the value returned by... (let [[x y [z]] [2 4 [8 9]]] (list x y z))
Answers:
• (2 4 8)
• (2 4 (8 9))
• [2 4 [8 9]]
81. How many ways can you safely share mutable data using Clojure?
Answers:
• 3
• 5
• 2
• 4
82. (letfn [ (t [] (true? (some true? ["false"])))] (t))
Answers:
• False because
"false" is a string
• True because
"false" is a string
• False because
"false" is not a string
• True because
"false" is not a string
• False because the string "false" is not the value
true
83. What is Clojure a dialect of?
Answers:
• C/C++
• Cobra
• Lisp
• Scheme
84. ________ evaluates all of the expressions provided to it in order and yields the last expression's value as its value.
Answers:
• def
• do
• fn
• let
85. Which of the following Clojure fragments calculates (4+2)*(5-3)?
Answers:
• (+ 4 2 (* (- 5
3)))
• 4+2*(5-3)
• 4 2 + 5 3 - *
• (* (+ 4 2) (- 5 3))
86. Clojure documentation can be accessed
Answers:
• All of the above
• through the
clojure.org website
• via the doc
function
• on
clojuredocs.org
87. REPL stands for _____
Answers:
• Rediscover
Enlightened Programs and Languages
• REPresentational
Language
• Read, Eval,
Process, Loop
• Read, Eval, Print, Loop
88. The map function is used to _____
Answers:
• apply a function to all elements in a collection and return
a sequence of the results
• aggregate the
elements in a collection using a given function and return the result as a
single value
• All of the above
• create a new Map
object containing the specified elements
89. Which statement about -> and comp is true?
Answers:
• -> and comp
are exactly the same, except the parameters are in the opposite order
• -> is a macro while comp is a higher order function
• comp is a macro
while -> is a higher order function
• -> is not a
valid identifier in clojure, but comp is
90. For the following code to evaluate without error, what needs to be added? (def regex "<a>(.*)</a>") (re-seq regex "<a>Ryan Kelker</a>")
Answers:
• Nothing. The
syntax is correct
• # symbol before
regex and after def
• # symbol before
regex in (re-seq)
• # symbol before the string in regex
• @ symbol when
defining regex
91. Agents _____
Answers:
• provide
thread-local variable bindings
• manage independent, asynchronous changes to a single location
• manage
independent, synchronous changes to a single location
• provide
thread-isolated transactions
92. (.split "Java String" " ") returns
Answers:
• Invalid
operation for string
• Syntax error
• A lazy-sequenced
array of strings
• A Java array of strings
93. The Clojure reader can be extended using _____
Answers:
• reader macros
• metadata
• tagged literals
• XML
1. A(n) ________ is a named Emacs object that represents something
editable, usually a file in your filesystem, but also the Clojure REPL or
debugger, for example.
Answers:
• Buffer
• paredit
• inferior-lisp
• Window
2. Refs _____
Answers:
• provide thread-local
variable bindings
• manage independent,
synchronous changes to a single location
•
provide thread-isolated transactions
• manage independent,
asynchronous changes to a single location
3. Vars _____
Answers:
•
provide thread-local variable bindings
• manage independent,
synchronous changes to a single location
• provide
thread-isolated transactions
• manage independent,
asynchronous changes to a single location
4. A function can be stored in a var or passed as an argument to
other functions.
Answers:
• True
• False
5. True or False? Sets are collections of unique items. They are
better than lists and vectors when duplicates aren't allowed.
Answers:
• False
• True
6. True or False? The Clojure language is homoiconic.
Answers:
• True
• False
7. lib-noir, Ring, and Compojure are all
examples of Clojure:
Answers:
• JSON service modules
• SOAP service modules
• HTTP
service modules
• API service modules
• REST service modules
8. STM stands for _____
Answers:
• Step, Translate,
Motion
• Safe Transactions in
Memory
• State Transfer Machine
•
Software Transactional Memory
9. Stack abstraction is supported in Clojure via
what three operations?
Answers:
• get, find, pop
• find, conj, get
• get, nth, find
• conj,
pop, peek
10. A multimethod is created using a
________form, and implementations of a multimethod are provided by ___________
form.
Answers:
•
defmulti, defmethod
• derive,
make-heiracrchy
• fill, fill-dispatch
• defmethod, defmulti
11. Locks _____
Answers:
• provide
thread-isolated transactions
• are a
low-level construct that should be avoided in most cases
• manage independent,
asynchronous changes to a single location
• provide thread-local
variable bindings
12. let is a _____
Answers:
• Reserved Keyword
• Macro
• Function
•
Special Form
13. A Clojure sequence is a Java
Answers:
• Iterable
• Map
•
Iterator
• List
14. True or False? Clojure is NOT an imperative
language.
Answers:
• True
• False
15. In many object-oriented languages,
________________ is a way to decouple a class from other objects upon which
that class depends.
Answers:
• chain of
responsibility
• the template method
•
dependency injection
• strategy pattern
16. True or False? Metadata is data about data,
and has no effect on the 'host' data.
Answers:
• False
• True
17. True or False? Clojure a functional
language.
Answers:
• True
• False
18. What is the syntax of the "if"
function?
Answers:
• (if
condition then-expr else-expr)
• (condition to-expr
else-expr)
• (condition if
then-expr else-expr)
•
(condition-if-then-expr-else expr)
19. Which is an example of a Clojure function
call?
Answers:
•
(function-name arg1 arg2 arg3)
• (method-name arg1 arg2
arg3)
• function-name (arg1,
arg2, arg3)
• methodName(arg1, arg2,
arg3)
20. What is significant about function names
that end with a "!"?
Answers:
• It warns users that
the function is deprecated.
• It serves as a warning
that the function in question may produce an unstable result.
• It is
a convention that indicates the function mutates some state.
• All functions that
mutate some state must end with a "!", or else you will get a
compiler error.
21. In Clojure, you can create a new class using
_____
Answers:
• All of
the above
• gen-class
• proxy
• deftype
22. Clojure strings are Java Strings and are
represented in exactly the same way, delimited by double quotes.
Answers:
• True
• FALSE
23. Which is a type of collection in Clojure?
Answers:
• None of these
• Set
• Vector
• All of
these
24. Which statement best describes protocols in
Clojure?
Answers:
• A protocol defines how
two programs communicate over a computer network.
• Clojure provides
several macros that make it easy to implement various network protocols.
• A
protocol defines an interface. But unlike Java interfaces, which must be
specified when a class is created, protocols can be attached to a class at any
time.
• Clojure uses the term
"protocol" to refer to what Java calls an "interface".
25. What is the function that evaluates a single
argument form?
Answers:
• eval
• test
• defn
• var
26. True or False? Arity is the number of
arguments a function can handle.
Answers:
• True
• False
27. Leiningen uses _____ to locate and manage
project dependencies
Answers:
• Ivy
• GitHub
• SourceForge
• Maven
28. What does the REPL tool do?
Answers:
•
Read-eval-print loop
• Read-enter-print look
• Repeat-eval-pair loop
• Read-eval-part loop
29. Which of the following code fragments
evaluates to 5?
Answers:
• ({:a 1 :b 3 :c 5} :c)
• All of
the above
• (get {:a 1 :b 3 :c 5}
:c)
• (:c {:a 1 :b 3 :c 5})
30. Clojure is hosted on the JVM (Java Virtual
Machine) and can use any Java library.
Answers:
• FALSE
• True
31. True or False? In Clojure a symbol can
contain characters that most imperative languages don't allow in variable
names. (Example: in Clojure you can have a symbol with the name +a-.)
Answers:
• False
• True
32. What does the "contains?" function
work on?
Answers:
• All of
these
• Vectors
• Maps
• Sets
33. Does Clojure have a metadata system that
allows for annotation of symbols and collections?
Answers:
• True
• False
34. True or False? Clojure programs only support
some Java classes and interfaces.
Answers:
• False
• True
35. To calculate the average of some numbers in
Clojure, your code would look like this:
Answers:
• def average (numbers):
return sum( numbers) / len( numbers)
• (defn
average [numbers] (/ (apply + numbers) (count numbers)))
• def average (numbers)
numbers.inject(: +) / numbers.length end
• public static double
average (double[] numbers) { double sum = 0; for (int i = 0; i <
numbers.length; i + +) { sum + = numbers[ i]; } return sum / numbers.length; }
36. Collections that classically support
last-in, first-out (LIFO) semantics are called ____________.
Answers:
• vectors
• contains
• indices
• stacks
37. What type does the following code result
in? {:a 1 "b" 2}
Answers:
• Array
• Vector
• Map
• List
38. Which statement about Clojure macros is
true?
Answers:
• Macros provide an
ad-hoc mechanism for improving the performance of critical code.
• Macros are basically a
glorified parameterizable search-replace mechanism. They are error prone, and
should be avoided at all costs.
• Macros
allow programmers to specify program transformations that occur during compile
time.
• Macros are useful, but
Clojure's implementation of them is very limited.
39. The reduce function is used to _____
Answers:
•
aggregate the elements in a collection using a given function and return the
result as a single value
• All of the above
• apply a function to
all elements in a collection and return a sequence of the results
• substract a given
amount from an integer value
40. How do you create an anonymous function?
Answers:
• prefix#
• #(double-expression)
•
#(single-expression)
• #{items}
41. :foo is an example of a(n) _____
Answers:
•
keyword
• variable name
• symbol
• atom
42. How do you add metadata to a symbol or
collection?
Answers:
• (class-name. args)
• {key-value-pairs}
• #"pattern"
•
^{key-value-pairs} object
43. What are sequences?
Answers:
• Ordered codes
• Specific collections
• Concrete lists
•
Logical views of collections
44. What do keywords begin with?
Answers:
• :
• -
• #
• ;
45. The following code will evaluate to true?
(defn +++ [n] (+ (inc n) 1)) (= (+++ 1) 3)
Answers:
• True
• Can't define a
reserved symbol
• + is reserved and
can't be re-defined
• Syntax error
• False
46. The two comment types that are defined by
the reader are:
Answers:
• textual comments and
multi-line comments
• custom comments and
code-snippets
• basic comments and
source comments
•
Single-line comments and Form-level comments
47. If you are already using Java or another JVM
language for RDBMS work, it’s likely that you’re using ______________, easily
the most popular Java object/ relational mapping library.
Answers:
•
Hibernate
• SLIME
• Korma
• Entity
48. A built-in Clojure "operation" may
be implemented as a...
Answers:
• Function
• All of
these
• Special Form
• Macro
49. What are the 3 phases Clojure code is
processed in?
Answers:
•
Read-time, compile-time, run-time
• Read-time,
compile-time, load-time
• Read-time,
gather-time, run-time
• There are actually 4
phases.
50. Clojure provides several "persistent"
data structures. Objects of these classes are _____
Answers:
• serializable
• stored in a database
•
immutable
• implemented in a way
that makes them robust in case of memory errors
51. Clojure is primarily an imperative language.
Answers:
• False
• True
52. How would you want to create a new Atom with
an initial value <value>?
Answers:
• (make-atom <value)
• (new 'Atom
<value>)
• (new-atom value)
• (new Atom
<value>)
• (atom
<value>)
53. What type does the following code result
in? [1 2 3 4]
Answers:
• List
• Map
• Vector
• Array
54. What is the literal syntax for maps?
Answers:
• {:a 1
:b 2}
• #{:a 1 :b 2}
• [:a 1 :b 2]
55. True or False? A lazy-sequence can hold all
the possible calculations of the Fibonacci sequence.
Answers:
• False
• True
56. We can use _____________ to create a table
with a specific name and define columns.
Answers:
• with-connection
• with-query-results
• transaction
•
create-table
57. What is generally the first step in
deploying your Clojure web application?
Answers:
•
Installing and configuring Leiningen or setting up and configuring an app
server.
• Copying the .war file
your build process is producing to your server.
• Restarting the
application
• Reverting your
application's .war file to a prior version.
58. What is the conventional first and last
character used to name vars intended to be bound to new, thread-local values?
Answers:
• (
• *
• "
• ^
59. What's a difference between quote (') and
syntax-quote (`) macro characters?
Answers:
• Quote (') fully
qualifies symbols, while syntax-quote (`) doesn't
•
Syntax-quote (`) fully qualifies symbols, while quote (') doesn't
• There is no difference
between quote (') and syntax-quote (`)
60. (= (map + '(1 2 3)) 3)
Answers:
• True
• False
• (1 2 3)
• 6
• 5
61. True or False? Function definitions must
appear before they're first used.
Answers:
• True
• False
62. Which statement regarding Clojure
"forms" is true?
Answers:
• Every form is a
function call, but not every function call is a form.
• Every
function call is a form, but not every form is a function call.
• The terms
"function call" and "form" are completely interchangeable.
• A form is like a
function call, except it invokes a macro instead.
63. ________ is a very low-level looping and
recursion operation that is usually not necessary.
Answers:
• reduce
• recur
• map
• leap
64. In Clojure >= 1.3, which of these follows
the naming conventions for dynamic objects? (def ^:dynamic *d* (atom [])) (def
^:dynamic d (atom []))
Answers:
• *d*,
but not d
• d, but not *d*
65. To represent a boxed decimal in Clojure, you
would use ____________.
Answers:
• Float
• float
• Fixnum
•
java.lang.Double
66. To represent a boxed decimal in Clojure, you
would use ____________.
Answers:
• Float
• float
• Fixnum
•
java.lang.Double
67. In Clojure, tail-call optimization is _____
Answers:
• done for every call
which is in a tail position
• only done for simple
recursion
• not
supported natively by the compiler, but could be simulated using thunks,
trampolines, and macros.
• impossible
68. You can use ___________ whenever you like if
you need a unique symbol, but its primary role is in helping us write hygienic
macros.
Answers:
• defmacro
• hygienic
• important-value
• gensym
69. Suppose you want to implement a set of
mutually-recursive functions. Which approach might you take?
Answers:
• Define
the functions using letfn
• Define the functions
locally using def
• Define the functions
using let
• Since Clojure only
supports simple recursion, you need to convert to an iterative algorithm.
70. True or False? (reset!) is used to set the
value of an atom.
Answers:
• False
• True
71. What provides synchronous changes to a
single piece of shared data?
Answers:
• Vars
• Agents
• Refs
• Atoms
72. What provides synchronous changes to a
single, thread-local value?
Answers:
• Atoms
• Refs
• Agents
• Var
73. True or False? In functional oriented
languages, you can't manipulate objects like in object oriented languages.
Answers:
• True
• False
74. If you want to create class that extends
another class, you must use _____
Answers:
• deftype
•
gen-class
• reify
• defrecord
75. The application of advice or other aspect
transformations is often called __________.
Answers:
• wrapping
•
weaving
• advising
• profiling
76. A "dynamic" var _____
Answers:
• has a value that is
shared across multiple threads
• has a
value that is related to the call stack, and can be used to pass contextual
information between functions that do not call each other directly
• must be expected to
change value at any time, even if there is no local code that changes it
• is a variable that has
mutable state
77. Atoms _____
Answers:
• manage
independent, synchronous changes to a single location
• manage independent,
asynchronous changes to a single location
• provide
thread-isolated transactions
• provide thread-local
variable bindings
78. A _______ is a construct that suspends some
body of code, evaluating it upon demand, when it is "deref"erenced.
Answers:
• deliver
• promise
• future
• delay
79. What is the Closure equivalent to
ClassName.class in Java?
Answers:
• Class.name
• (ClassName.class)
• ClassName.CLASS
•
ClassName
80. What's the value returned by... (let [[x y
[z]] [2 4 [8 9]]] (list x y z))
Answers:
• (2 4
8)
• (2 4 (8 9))
• [2 4 [8 9]]
81. How many ways can you safely share mutable
data using Clojure?
Answers:
• 3
• 5
• 2
• 4
82. (letfn [ (t [] (true? (some true?
["false"])))] (t))
Answers:
• False because
"false" is a string
• True because
"false" is a string
• False because
"false" is not a string
• True because
"false" is not a string
• False
because the string "false" is not the value true
83. What is Clojure a dialect of?
Answers:
• C/C++
• Cobra
• Lisp
• Scheme
84. ________ evaluates all of the expressions
provided to it in order and yields the last expression's value as its value.
Answers:
• def
• do
• fn
• let
85. Which of the following Clojure fragments
calculates (4+2)*(5-3)?
Answers:
• (+ 4 2 (* (- 5 3)))
• 4+2*(5-3)
• 4 2 + 5 3 - *
• (* (+
4 2) (- 5 3))
86. Clojure documentation can be accessed
Answers:
• All of
the above
• through the
clojure.org website
• via the doc function
• on clojuredocs.org
87. REPL stands for _____
Answers:
• Rediscover Enlightened
Programs and Languages
• REPresentational
Language
• Read, Eval, Process,
Loop
• Read,
Eval, Print, Loop
88. The map function is used to _____
Answers:
• apply
a function to all elements in a collection and return a sequence of the results
• aggregate the elements
in a collection using a given function and return the result as a single value
• All of the above
• create a new Map
object containing the specified elements
89. Which statement about -> and comp is
true?
Answers:
• -> and comp are
exactly the same, except the parameters are in the opposite order
• ->
is a macro while comp is a higher order function
• comp is a macro while
-> is a higher order function
• -> is not a valid
identifier in clojure, but comp is
90. For the following code to evaluate without
error, what needs to be added? (def regex
"<a>(.*)</a>") (re-seq regex "<a>Ryan
Kelker</a>")
Answers:
• Nothing. The syntax is
correct
• # symbol before regex
and after def
• # symbol before regex
in (re-seq)
• #
symbol before the string in regex
• @ symbol when defining
regex
91. Agents _____
Answers:
• provide thread-local
variable bindings
• manage
independent, asynchronous changes to a single location
• manage independent,
synchronous changes to a single location
• provide
thread-isolated transactions
92. (.split "Java String" "
") returns
Answers:
• Invalid operation for
string
• Syntax error
• A lazy-sequenced array
of strings
• A Java
array of strings
93. The Clojure reader can be extended using
_____
Answers:
• reader macros
• metadata
• tagged
literals
• XML
No comments:
Post a Comment