MCQs > IT & Programming > Clojure MCQs > Basic Clojure MCQs

Basic Clojure MCQ

1. A Clojure sequence is a Java

Answer

Correct Answer: Iterator

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: ClassName

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: 3

Note: This Question is unanswered, help us to find answer for this one

4. What's the value returned by... (let [[x y [z]] [2 4 [8 9]]] (list x y z))

Answer

Correct Answer: (2 4 8)

Note: This Question is unanswered, help us to find answer for this one

5. The Clojure reader can be extended using _____

Answer

Correct Answer: tagged literals

Note: This Question is unanswered, help us to find answer for this one

6. Refs _____

Answer

Correct Answer: provide thread-isolated transactions

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: weaving

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: delay

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: gen-class

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Var

Note: This Question is unanswered, help us to find answer for this one

11. Atoms _____

Answer

Correct Answer: manage independent, synchronous changes to a single location

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: A Java array of strings

Note: This Question is unanswered, help us to find answer for this one

13. Agents _____

Answer

Correct Answer: manage independent, asynchronous changes to a single location

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

16. Which statement best describes protocols in Clojure?

Answer

Correct Answer: 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.

Note: This Question is unanswered, help us to find answer for this one

17. Which of the following code fragments evaluates to 5?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

19. Clojure documentation can be accessed

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

21. Which is a type of collection in Clojure?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

22. What does the REPL tool do?

Answer

Correct Answer: Read-eval-print loop

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

24. Which of the following Clojure fragments calculates (4+2)*(5-3)?

Answer

Correct Answer: (* (+ 4 2) (- 5 3))

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

27. What is the syntax of the "if" function?

Answer

Correct Answer: (if condition then-expr else-expr)

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

29. True or False? Clojure a functional language.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

32. Leiningen uses _____ to locate and manage project dependencies

Answer

Correct Answer: Maven

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: eval

Note: This Question is unanswered, help us to find answer for this one

34. Which is an example of a Clojure function call?

Answer

Correct Answer: (function-name arg1 arg2 arg3)

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Map

Note: This Question is unanswered, help us to find answer for this one

36. How do you create an anonymous function?

Answer

Correct Answer: #(single-expression)

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: stacks

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

39. What is significant about function names that end with a "!"?

Answer

Correct Answer: It is a convention that indicates the function mutates some state.

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: ^{key-value-pairs} object

Note: This Question is unanswered, help us to find answer for this one

41. lib-noir, Ring, and Compojure are all examples of Clojure:

Answer

Correct Answer: HTTP service modules

Note: This Question is unanswered, help us to find answer for this one

42. To calculate the average of some numbers in Clojure, your code would look like this:

Answer

Correct Answer: (defn average [numbers] (/ (apply + numbers) (count numbers)))

Note: This Question is unanswered, help us to find answer for this one

43. What are sequences?

Answer

Correct Answer: Logical views of collections

Note: This Question is unanswered, help us to find answer for this one

44. The map function is used to _____

Answer

Correct Answer: apply a function to all elements in a collection and return a sequence of the results

Note: This Question is unanswered, help us to find answer for this one

45. Which statement about Clojure macros is true?

Answer

Correct Answer: Macros allow programmers to specify program transformations that occur during compile time.

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: conj, pop, peek

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: keyword

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Hibernate

Note: This Question is unanswered, help us to find answer for this one

50. What type does the following code result in? [1 2 3 4]

Answer

Correct Answer: Vector

Note: This Question is unanswered, help us to find answer for this one

51. What are the 3 phases Clojure code is processed in?

Answer

Correct Answer: Read-time, compile-time, run-time

Note: This Question is unanswered, help us to find answer for this one

52. The reduce function is used to _____

Answer

Correct Answer: aggregate the elements in a collection using a given function and return the result as a single value

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

55. Clojure provides several "persistent" data structures. Objects of these classes are _____

Answer

Correct Answer: immutable

Note: This Question is unanswered, help us to find answer for this one

56. The following code will evaluate to true? (defn +++ [n] (+ (inc n) 1)) (= (+++ 1) 3)

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

57. How would you want to create a new Atom with an initial value <value>?

Answer

Correct Answer: (atom <value>)

Note: This Question is unanswered, help us to find answer for this one

58. Clojure is primarily an imperative language.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

59. What is generally the first step in deploying your Clojure web application?

Answer

Correct Answer: Installing and configuring Leiningen or setting up and configuring an app server.

Note: This Question is unanswered, help us to find answer for this one

60. ________ evaluates all of the expressions provided to it in order and yields the last expression's value as its value.

Answer

Correct Answer: do

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Buffer

Note: This Question is unanswered, help us to find answer for this one

62. A multimethod is created using a ________form, and implementations of a multimethod are provided by ___________ form.

Answer

Correct Answer: defmulti, defmethod

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

64. What is the literal syntax for maps?

Answer

Correct Answer: {:a 1 :b 2}

Note: This Question is unanswered, help us to find answer for this one

65. In many object-oriented languages, ________________ is a way to decouple a class from other objects upon which that class depends.

Answer

Correct Answer: dependency injection

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: *

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: recur

Note: This Question is unanswered, help us to find answer for this one

68. You can use ___________ whenever you like if you need a unique symbol, but its primary role is in helping us write hygienic macros.

Answer

Correct Answer: gensym

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

71. Which statement about -> and comp is true?

Answer

Correct Answer: -> is a macro while comp is a higher order function

Note: This Question is unanswered, help us to find answer for this one

72. What's a difference between quote (') and syntax-quote (`) macro characters?

Answer

Correct Answer: Syntax-quote (`) fully qualifies symbols, while quote (') doesn't

Note: This Question is unanswered, help us to find answer for this one

73. In Clojure, tail-call optimization is _____

Answer

Correct Answer: not supported natively by the compiler, but could be simulated using thunks, trampolines, and macros.

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: java.lang.Double

Note: This Question is unanswered, help us to find answer for this one

75. Locks _____

Answer

Correct Answer: are a low-level construct that should be avoided in most cases

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

77. Which statement regarding Clojure "forms" is true?

Answer

Correct Answer: Every function call is a form, but not every form is a function call.

Note: This Question is unanswered, help us to find answer for this one

78. For the following code to evaluate without error, what needs to be added? (def regex "<a>(.*)</a>") (re-seq regex "<a>Ryan Kelker</a>")

Answer

Correct Answer: # symbol before the string in regex

Note: This Question is unanswered, help us to find answer for this one

search
Clojure Subjects