Frequently asked questions and answers of D in Programming Technologies of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best D Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download D 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 D programming language?
Answer-1: D is a high-level, statically-typed, and compiled programming language designed for system and application programming.
Question-2. Who created the D programming language?
Answer-2: The D language was created by Walter Bright of Digital Mars in 2001.
Question-3. What are the key features of D programming language?
Answer-3: Key features include garbage collection, modularity, native machine code compilation, and mixins.
Question-4. How does D differ from C++?
Answer-4: D simplifies syntax, adds garbage collection, and offers better module management compared to C++.
Question-5. What type of programming paradigms does D support?
Answer-5: D supports multiple paradigms, including imperative, object-oriented, and functional programming.
Question-6. What is a module in D?
Answer-6: A module is a file containing D code, and each module acts as a separate namespace.
Question-7. What is the file extension used for D source files?
Answer-7: The file extension for D source files is .d.
Question-8. How do you declare a variable in D?
Answer-8: Variables are declared with the syntax: dataType variableName;, for example, int x;.
Question-9. What are ranges in D?
Answer-9: Ranges are a key feature for iterating over collections efficiently, often used with D's algorithms.
Question-10. Does D support garbage collection?
Answer-10: Yes, D includes garbage collection for automatic memory management.
Question-11. What is import in D?
Answer-11: import is used to include modules, similar to #include in C++ or import in Python.
Question-12. What is immutable in D?
Answer-12: immutable declares that a variable's value cannot be changed after initialization.
Question-13. How does D handle arrays?
Answer-13: D supports dynamic, static, and associative arrays, offering flexibility in data storage.
Question-14. What are templates in D?
Answer-14: Templates allow generic programming by enabling code to be written without specifying data types.
Question-15. What is a mixin in D?
Answer-15: A mixin allows embedding strings or code within other code, enabling meta-programming.
Question-16. How do you write a function in D?
Answer-16: Functions are written as returnType functionName(parameters) { body }.
Question-17. What is a struct in D?
Answer-17: A struct is a user-defined type that groups related variables under one data structure.
Question-18. What is unittest in D?
Answer-18: unittest is a built-in feature for writing and running unit tests directly in the code.
Question-19. How do you handle exceptions in D?
Answer-19: Exceptions are handled using try, catch, and finally blocks, similar to Java or C#.
Question-20. What is the purpose of the auto keyword in D?
Answer-20: auto lets the compiler infer the variable's type based on its initial value.
Question-21. Does D support overloading?
Answer-21: Yes, D supports both function and operator overloading.
Question-22. What is alias in D?
Answer-22: alias creates an alternative name for an existing type or symbol, improving code readability.
Question-23. What is a delegate in D?
Answer-23: A delegate is a function pointer that retains a reference to its enclosing environment.
Question-24. How does D support threading?
Answer-24: D provides built-in libraries like std.concurrency for creating and managing threads.
Question-25. What is a class in D?
Answer-25: A class is a reference type that supports inheritance and encapsulates data and methods.
Question-26. What is the difference between struct and class in D?
Answer-26: struct is a value type, while class is a reference type with inheritance capabilities.
Question-27. How do you define an interface in D?
Answer-27: Interfaces are defined using the interface keyword and contain only abstract methods.
Question-28. What is the purpose of scope in D?
Answer-28: scope is used for managing resource cleanup, ensuring destructors are called as necessary.
Question-29. Does D support lambda expressions?
Answer-29: Yes, D supports lambda expressions, written as (parameters) => expression;.
Question-30. What is the static keyword in D?
Answer-30: static is used to define members that belong to the type itself rather than an instance.
Question-31. How do you include external libraries in a D program?
Answer-31: External libraries can be included using dub, D's package manager.
Question-32. What are traits in D?
Answer-32: Traits provide compile-time reflection capabilities, allowing introspection of types.
Question-33. What is scope(exit) in D?
Answer-33: scope(exit) executes a block of code when the enclosing scope is exited.
Question-34. How is a foreach loop used in D?
Answer-34: foreach iterates over collections, e.g., foreach(item; array) { body }.
Question-35. What are associative arrays in D?
Answer-35: Associative arrays map keys to values and are declared as dataType[keyType].
Question-36. Does D support modules natively?
Answer-36: Yes, D supports modules natively, promoting modular programming.
Question-37. What are contracts in D?
Answer-37: Contracts allow specifying preconditions, postconditions, and invariants in code.
Question-38. What is the default visibility of members in D?
Answer-38: The default visibility of members is private.
Question-39. How does D support functional programming?
Answer-39: D supports functional programming with features like higher-order functions, immutability, and ranges.
Question-40. What is CTFE in D?
Answer-40: CTFE (Compile-Time Function Execution) allows functions to execute at compile time.
Question-41. What is a ref parameter in D?
Answer-41: A ref parameter passes a variable by reference, allowing modifications to the original value.
Question-42. What is pure in D?
Answer-42: The pure keyword marks functions as free of side effects, ensuring they depend only on input arguments.
Question-43. What is a shared type in D?
Answer-43: shared indicates that a variable can be safely accessed by multiple threads.
Question-44. How does D handle string manipulation?
Answer-44: D provides a rich set of functions for string manipulation in the std.string module.
Question-45. What is a lazy parameter in D?
Answer-45: A lazy parameter delays evaluation of its argument until it is used in the function.
Question-46. What is synchronized in D?
Answer-46: synchronized is used for locking and thread synchronization in multithreaded code.
Question-47. What is the difference between immutable and const in D?
Answer-47: immutable ensures the value never changes, while const allows the value to change outside its scope.
Question-48. What are templates in D used for?
Answer-48: Templates enable generic and reusable code that adapts to different data types.
Question-49. Does D support RAII?
Answer-49: Yes, D supports RAII (Resource Acquisition Is Initialization) for resource management.
Question-50. How do you compile a D program?
Answer-50: Use the dmd compiler: dmd file.d -o executable.
Frequently Asked Question and Answer on D
D Interview Questions and Answers in PDF form Online
D Questions with Answers
D Trivia MCQ Quiz