Do you know that? 1% jobs posted on Elance are for Legal next

Contact Email: teammmrem@yahoo.com

<< All Upwork (oDesk) and Elance Tests << Elance test answers << IT & Programming category

Test answers for Clojure 2016

(93) Last updated: January 22
Elance • IT & Programming
Questions and answers are regularly updated. Answered and not answered tests questions.

This helps getting job: Hundreds of (cover letter examples , interview questions , profile samples ) • Earn on Upwork (oDesk)
Job assistance: jobs popularityfreelance rates

Popular test answers: HTML, .Net, CSS, English, SEO, Photoshop, iOS, Java, Android, Ruby, Python, JavaScript

See all 6 tests answers updated

Find Upwork (oDesk) and Elance test answers on this website:



Collapse | Expand

93 Answered Test Questions:

1. What is Clojure a dialect of?

Answers:

• C/C++

• Cobra

• Lisp

• Scheme

2. True or False? Clojure is NOT an imperative language.

Answers:

• True

• False

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. 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

5. True or False? Metadata is data about data, and has no effect on the 'host' data.

Answers:

• False

• True

6. ________ 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

7. True or False? Clojure a functional language.

Answers:

• True

• False

8. 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)

9. 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)

10. 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))

11. 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.

12. A function can be stored in a var or passed as an argument to other functions.

Answers:

• True

• False

13. In Clojure, you can create a new class using _____

Answers:

• All of the above

• gen-class

• proxy

• deftype

14. Clojure strings are Java Strings and are represented in exactly the same way, delimited by double quotes.

Answers:

• True

• FALSE

15. Which is a type of collection in Clojure?

Answers:

• None of these

• Set

• Vector

• All of these

16. True or False? Sets are collections of unique items. They are better than lists and vectors when duplicates aren't allowed.

Answers:

• False

• True

17. 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".

18. What is the function that evaluates a single argument form?

Answers:

• eval

• test

• defn

• var

19. True or False? Arity is the number of arguments a function can handle.

Answers:

• True

• False

20. Leiningen uses _____ to locate and manage project dependencies

Answers:

• Ivy

• GitHub

• SourceForge

• Maven

21. Clojure documentation can be accessed

Answers:

• All of the above

• through the clojure.org website

• via the doc function

• on clojuredocs.org

22. What does the REPL tool do?

Answers:

• Read-eval-print loop

• Read-enter-print look

• Repeat-eval-pair loop

• Read-eval-part loop

23. 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})

24. Clojure is hosted on the JVM (Java Virtual Machine) and can use any Java library.

Answers:

• FALSE

• True

25. 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

26. What does the "contains?" function work on?

Answers:

• All of these

• Vectors

• Maps

• Sets

27. Does Clojure have a metadata system that allows for annotation of symbols and collections?

Answers:

• True

• False

28. True or False? Clojure programs only support some Java classes and interfaces.

Answers:

• False

• True

29. 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; }

30. True or False? The Clojure language is homoiconic.

Answers:

• True

• False

31. Collections that classically support last-in, first-out (LIFO) semantics are called ____________.

Answers:

• vectors

• contains

• indices

• stacks

32. What type does the following code result in?       {:a 1 "b" 2}

Answers:

• Array

• Vector

• Map

• List

33. 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.

34. 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

35. 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

36. How do you create an anonymous function?

Answers:

• prefix#

• #(double-expression)

• #(single-expression)

• #{items}

37. :foo is an example of a(n) _____

Answers:

• keyword

• variable name

• symbol

• atom

38. How do you add metadata to a symbol or collection?

Answers:

• (class-name. args)

• {key-value-pairs}

• #"pattern"

• ^{key-value-pairs} object

39. What are sequences?

Answers:

• Ordered codes

• Specific collections

• Concrete lists

• Logical views of collections

40. What do keywords begin with?

Answers:

• :

• -

• #

• ;

41. 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

42. 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

43. REPL stands for _____

Answers:

• Rediscover Enlightened Programs and Languages

• REPresentational Language

• Read, Eval, Process, Loop

• Read, Eval, Print, Loop

44. 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

45. 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

46. A built-in Clojure "operation" may be implemented as a...

Answers:

• Function

• All of these

• Special Form

• Macro

47. STM stands for _____

Answers:

• Step, Translate, Motion

• Safe Transactions in Memory

• State Transfer Machine

• Software Transactional Memory

48. Stack abstraction is supported in Clojure via what three operations?

Answers:

• get, find, pop

• find, conj, get

• get, nth, find

• conj, pop, peek

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. 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

55. What is the literal syntax for maps?

Answers:

• {:a 1 :b 2}

• #{:a 1 :b 2}

• [:a 1 :b 2]

56. True or False? A lazy-sequence can hold all the possible calculations of the Fibonacci sequence.

Answers:

• False

• True

57. 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

58. We can use _____________ to create a table with a specific name and define columns.

Answers:

• with-connection

• with-query-results

• transaction

• create-table

59. 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

60. 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.

61. What is the conventional first and last character used to name vars intended to be bound to new, thread-local values?

Answers:

• (

• *

• "

• ^

62. 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 (`)

63. (= (map + '(1 2 3)) 3)

Answers:

• True

• False

• (1 2 3)

• 6

• 5

64. True or False? Function definitions must appear before they're first used.

Answers:

• True

• False

65. 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.

66. ________ is a very low-level looping and recursion operation that is usually not necessary.

Answers:

• reduce

• recur

• map

• leap

67. 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

68. 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*

69. To represent a boxed decimal in Clojure, you would use ____________.

Answers:

• Float

• float

• Fixnum

• java.lang.Double

70. To represent a boxed decimal in Clojure, you would use ____________.

Answers:

• Float

• float

• Fixnum

• java.lang.Double

71. 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

72. 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

73. 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

74. let is a _____

Answers:

• Reserved Keyword

• Macro

• Function

• Special Form

75. 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.

76. True or False? (reset!) is used to set the value of an atom.

Answers:

• False

• True

77. 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

78. What provides synchronous changes to a single piece of shared data?

Answers:

• Vars

• Agents

• Refs

• Atoms

79. What provides synchronous changes to a single, thread-local value?

Answers:

• Atoms

• Refs

• Agents

• Var

80. True or False? In functional oriented languages, you can't manipulate objects like in object oriented languages.

Answers:

• True

• False

81. (.split "Java String" " ") returns

Answers:

• Invalid operation for string

• Syntax error

• A lazy-sequenced array of strings

• A Java array of strings

82. If you want to create class that extends another class, you must use _____

Answers:

• deftype

• gen-class

• reify

• defrecord

83. The application of advice or other aspect transformations is often called __________.

Answers:

• wrapping

• weaving

• advising

• profiling

84. 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

85. 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

86. A _______ is a construct that suspends some body of code, evaluating it upon demand, when it is "deref"erenced.

Answers:

• deliver

• promise

• future

• delay

87. 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

88. The Clojure reader can be extended using _____

Answers:

• reader macros

• metadata

• tagged literals

• XML

89. What is the Closure equivalent to ClassName.class in Java?

Answers:

• Class.name

• (ClassName.class)

• ClassName.CLASS

• ClassName

90. 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]]

91. A Clojure sequence is a Java

Answers:

• Iterable

• Map

• Iterator

• List

92. How many ways can you safely share mutable data using Clojure?

Answers:

• 3

• 5

• 2

• 4

93. (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