Questions
We gained a lot of knowledge in this chapter, so don’t be hard on yourself if you can’t answer all of these questions on your first attempt:
- How many superclasses can a class inherit from in its class definition?
- If you want to create a new class that inherits from many parent classes, how could you achieve this?
- Describe polymorphism and give an example of how it could be useful.
- Explain the difference between
instance
fields/methods andstatic
fields/methods. - What is the purpose of starting your class name, field name, or method name with an underscore?
- Can you remember how to initiate class fields from a constructor without the need for a constructor body?
- Give some examples of where you would use generics and why that would benefit your code’s type safety.
- What happens to your code execution if you call an
async
method with or withoutawait
?