.net full stack foundation coursera week 3 answers
Class & Interface - Practice Quiz
1. What is an abstract class in C#?
- A class that cannot be instantiated and can only contain static methods
- A class that can be instantiated and can only contain instance methods
- A class that cannot be instantiated and can contain abstract and non-abstract methods
- A class that can be instantiated and can only contain abstract methods
2. What is an interface in C#?
- A class that cannot be instantiated and can contain both abstract and non-abstract methods
- A class that can be instantiated and can contain both abstract and non-abstract methods
- A contract that defines a set of methods and properties that a class must implement
- A class that can be instantiated and can only contain abstract methods
3. What is the main difference between an interface and an abstract class in C#?
- An interface can contain both abstract and non-abstract methods, while an abstract class can only contain abstract methods
- An interface can be instantiated, while an abstract class cannot be instantiated
- An interface can only contain abstract methods and properties, while an abstract class can contain both abstract and non-abstract methods
- An abstract class can provide a default implementation for some methods, while an interface cannot provide any implementation
4. What is a static class in C#?
- A class that can be instantiated and can contain static methods only
- A class that can be inherited and can contain both static and non-static methods
- A class that can be instantiated and can contain both static and non-static methods
- A class that cannot be instantiated and can contain only static methods and properties
5. Which of the following statements about indexers in C# is correct?
- Indexers are used to access properties of an object using an index
- Indexers can only be used with arrays
- Indexers can only be used to retrieve data from an object, not to modify it
- All of the above statements are true
Property & Indexers -Practice Quiz
6. What is the purpose of an exception in C#?
- To terminate the program execution
- To handle errors or unexpected situations in a program
- To skip a block of code
- To reduce the size of the program
7. What is a property in C#?
- A method that returns a specific type of object
- A type of exception used for handling null values
- A way to add metadata to a program element
- A member of a class or struct that provides access to a private field
8. What is an indexer in C#?
- A class that provides a set of methods to handle exceptions thrown by the application.
- A class that allows a developer to attach additional data to a type or method.
- A class that provides a convenient way to encapsulate an array of values and access them using an index.
- A class that provides a way to define a single property that can be accessed using multiple keys or indexes.