Frequently asked questions and answers of Nimrod in Programming Technologies of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best Nimrod Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download Nimrod FAQs in PDF form online for academic course, jobs preparations and for certification exams .
Intervew Quizz is an online portal with frequently asked interview, viva and trivia questions and answers on various subjects, topics of kids, school, engineering students, medical aspirants, business management academics and software professionals.
Question-1. What is Nim?
Answer-1: Nim is a statically typed, compiled programming language that focuses on performance, readability, and metaprogramming.
Question-2. What was Nim?s original name?
Answer-2: Nim was originally called Nimrod but was renamed to Nim in 2014.
Question-3. Who created Nim?
Answer-3: Nim was created by Andreas Rumpf.
Question-4. What are the key features of Nim?
Answer-4: Nim features performance like C, syntax similar to Python, and powerful metaprogramming.
Question-5. How do you declare a variable in Nim?
Answer-5: Using var: var x: int = 10.
Question-6. What is the difference between let and var in Nim?
Answer-6: let declares an immutable variable, while var allows reassignment.
Question-7. What data types does Nim support?
Answer-7: Integers, floats, strings, arrays, sequences, tuples, objects, and more.
Question-8. How do you define a function in Nim?
Answer-8: Using the proc keyword: proc add(a, b: int): int = return a + b.
Question-9. What is a seq in Nim?
Answer-9: seq[T] is a dynamic sequence (resizable array) similar to lists in Python.
Question-10. How do you define a loop in Nim?
Answer-10: Using for: for i in 1..10: echo i.
Question-11. What is the syntax for a conditional statement in Nim?
Answer-11: if x > 10: echo "Big" elif x == 10: echo "Equal" else: echo "Small".
Question-12. How do you concatenate strings in Nim?
Answer-12: Using &: "Hello" & " World".
Question-13. What is Nim?s package manager?
Answer-13: Nimble is the official package manager for Nim.
Question-14. How do you install a package in Nim?
Answer-14: nimble install
Question-15. What are the main compilation targets of Nim?
Answer-15: Nim compiles to C, C++, and JavaScript.
Question-16. How do you compile a Nim program?
Answer-16: Using nim c
Question-17. What is metaprogramming in Nim?
Answer-17: Metaprogramming allows code generation and compile-time execution using macros.
Question-18. How do you define a tuple in Nim?
Answer-18: let t = (name: "Alice", age: 30).
Question-19. How do you access tuple elements?
Answer-19: t.name or t.age.
Question-20. How do you declare an array in Nim?
Answer-20: var arr: array[3, int] = [1, 2, 3].
Question-21. What is the difference between an array and seq in Nim?
Answer-21: array has a fixed size, while seq is dynamically resizable.
Question-22. How do you define an object in Nim?
Answer-22: type Person = object name: string age: int.
Question-23. What is a ref object in Nim?
Answer-23: A ref object is allocated on the heap and supports inheritance.
Question-24. How do you define a generic function in Nim?
Answer-24: proc add[T](a, b: T): T = return a + b.
Question-25. How do you implement exception handling in Nim?
Answer-25: Using try, except: try: echo 10 div 0 except: echo "Error".
Question-26. What is defer used for in Nim?
Answer-26: defer executes code at the end of a function?s scope.
Question-27. How do you use multiple return values in Nim?
Answer-27: Using tuples: proc values(): (int, string) = return (42, "Answer").
Question-28. What is when used for in Nim?
Answer-28: when is used for compile-time conditionals.
Question-29. How do you import a module in Nim?
Answer-29: Using import moduleName.
Question-30. How do you write a lambda function in Nim?
Answer-30: let square = (x: int) => x * x.
Question-31. How do you format a string in Nim?
Answer-31: Using &: let name = "Bob"; echo "Hello, " & name.
Question-32. How do you check the length of a sequence?
Answer-32: len(seq).
Question-33. How do you append an element to a sequence?
Answer-33: seq.add(42).
Question-34. What is Nim?s standard way to read user input?
Answer-34: var name: string; readLine(stdin, name).
Question-35. How do you measure execution time in Nim?
Answer-35: Using import times and cpuTime().
Question-36. What does discard do in Nim?
Answer-36: It ignores the return value of a function.
Question-37. How do you create a set in Nim?
Answer-37: var s = {1, 2, 3}.
Question-38. How do you check if a key exists in a table?
Answer-38: if "key" in myTable: echo myTable["key"].
Question-39. What are the benefits of Nim over Python?
Answer-39: Nim is faster, statically typed, and compiles to C for better performance.
Question-40. How do you create a coroutine in Nim?
Answer-40: Using async and await.
Question-41. How do you spawn a new thread in Nim?
Answer-41: Using spawn: spawn myFunction().
Question-42. How do you access command-line arguments?
Answer-42: import os; let args = commandLineParams().
Question-43. How do you handle JSON in Nim?
Answer-43: Using import json and parseJson("{\"key\": \"value\"}").
Question-44. What is mixins used for in Nim?
Answer-44: It allows methods to be injected into objects dynamically.
Question-45. What is inline in Nim?
Answer-45: inline suggests that the compiler should inline a function for better performance.
Question-46. How do you create an alias for a type?
Answer-46: type Age = int.
Question-47. How do you create a macro in Nim?
Answer-47: macro myMacro(): untyped = quote do: echo "Hello"
Question-48. How do you check the type of a variable?
Answer-48: typeof(x).
Question-49. How do you generate documentation in Nim?
Answer-49: Using nim doc
Question-50. How do you run a Nim script without compilation?
Answer-50: Using nim r
Frequently Asked Question and Answer on Nimrod
Nimrod Interview Questions and Answers in PDF form Online
Nimrod Questions with Answers
Nimrod Trivia MCQ Quiz