🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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 →
  1. Q1. Making a field private and allowing changes only through a method that validates input is:
  2. Q2. An interface PaymentMethod with a method pay(), used without knowing how each payment works, is an example of:
  3. Q3. Which statement is correct?
  4. Q4. In Python, what happens when you try to create an object of a class with an @abstractmethod that isn't implemented?
  5. Q5. Why is a setter like setAge(int a) { age = a; } weak encapsulation?
  6. Q6. What does this print? (code)
  7. Q7. In Python, what does self.balance (double underscore) do?
  8. Q8. Which question does abstraction answer?
  9. Q9. A new WhatsAppNotifier is added. Why does remind(notifier, to) not need any change?
  10. Q10. What does this print? (code)