Dive deep into macros, metaprogramming, runtime reflection, and Scala Meta utilities with these 30 essential MCQs. Enhance your understanding of Scala’s advanced capabilities for code generation and type manipulation.
macrodefcompilereflectscala.reflect.macros.blackbox.Contextscala.meta.macrosjava.lang.reflectscalaz.macrosscala.runtimescala.reflectscala.meta.reflectscala.util.reflectTypeTag in Scala?
Manifest in Scala?
Class objects in Java Reflectionscala.reflect.runtime.universeTypeTag and ManifestToolBox in Scala Reflection API?
TypeTag differ from ClassTag?
TypeTag provides full type information, while ClassTag focuses on erased typesClassTag is used for runtime reflection onlyTypeTag cannot access generic typesClassTag is faster but less preciseToolBox.evalManifest.invokeTypeTag.executeReflect.runTree in Scala Meta?
TreeParserToolBoxMacroUtilsSemanticDB in Scala Meta?
ScalametaParserSemanticDBToolBoxAST| Qno | Answer (Option with the text) |
|---|---|
| 1 | B) To generate code at compile-time |
| 2 | C) Type-safe code generation |
| 3 | A) macro |
| 4 | B) Abstract syntax trees (ASTs) |
| 5 | B) Semantic analysis phase |
| 6 | A) They cannot access runtime data |
| 7 | A) scala.reflect.macros.blackbox.Context |
| 8 | B) To eliminate boilerplate code |
| 9 | A) Inline methods and quotes |
| 10 | C) They lack a stable API |
| 11 | B) To inspect and modify program structure at runtime |
| 12 | B) scala.reflect |
| 13 | A) A runtime representation of a type |
| 14 | A) A deprecated way to access type information |
| 15 | D) All of the above |
| 16 | D) All of the above |
| 17 | A) A utility to execute Scala code at runtime |
| 18 | A) TypeTag provides full type information, while ClassTag focuses on erased types |
| 19 | D) All of the above |
| 20 | A) ToolBox.eval |
| 21 | B) Compile-time code analysis and transformation |
| 22 | A) Scala Meta |
| 23 | A) A way to construct and deconstruct syntax trees |
| 24 | A) A representation of Scala code |
| 25 | B) Inline and quotes |
| 26 | B) Parser |
| 27 | A) A database for storing semantic information about Scala code |
| 28 | B) SemanticDB |
| 29 | B) To simplify the creation of compilers and code analysis tools |
| 30 | D) All of the above |