← All topics
Quiz: Encapsulation and Abstraction: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. Making a field private and allowing changes only through a method that validates input is:
- Q2. An interface PaymentMethod with a method pay(), used without knowing how each payment works, is an example of:
- Q3. Which statement is correct?
- Q4. In Python, what happens when you try to create an object of a class with an @abstractmethod that isn't implemented?
- Q5. Why is a setter like setAge(int a) { age = a; } weak encapsulation?
- Q6. What does this print? (code)
- Q7. In Python, what does self.balance (double underscore) do?
- Q8. Which question does abstraction answer?
- Q9. A new WhatsAppNotifier is added. Why does remind(notifier, to) not need any change?
- Q10. What does this print? (code)