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. (letfn [ (t [] (true? (some true? ["false"])))] (t))

Answer

Correct Answer: False because the string "false" is not the value true

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

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

7. Refs _____

Answer

Correct Answer: provide thread-isolated transactions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

30. True or False? Clojure a functional language.

Answer

Correct Answer: True

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

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

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

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

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

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

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

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

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

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

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

41. The two comment types that are defined by the reader are:

Answer

Correct Answer: Single-line comments and Form-level comments

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

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

43. What do keywords begin with?

Answer

Correct Answer: :

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

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

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

46. What are sequences?

Answer

Correct Answer: Logical views of collections

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

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

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

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

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

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

Answer

Correct Answer: keyword

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

52. REPL stands for _____

Answer

Correct Answer: Read, Eval, Print, Loop

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

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

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

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

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

57. STM stands for _____

Answer

Correct Answer: Software Transactional Memory

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

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

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

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

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

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

63. Clojure is primarily an imperative language.

Answer

Correct Answer: False

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

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

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

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

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

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

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

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

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

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

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

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

Answer

Correct Answer: False

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

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

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

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

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

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

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

81. Vars _____

Answer

Correct Answer: provide thread-local variable bindings

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

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

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

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