โ† Barclays questions

Implement polymorphism and encapsulation; functions and classes

Filed under Barclays

Free read 3 of 3

Bundle data and methods and hide the internals. Example: class BankAccount with a private balance and public deposit() and withdraw() that validate input, so outside code cannot set an invalid balance.

The question

Implement polymorphism and encapsulation in OOP, and discuss functions and classes. The language was not specified, so state your choice.

Approach

  1. Bundle data and methods and hide the internals. Example: class BankAccount with a private balance and public deposit() and withdraw() that validate input, so outside code cannot set an invalid balance.

Tips

  • What they are testing: Whether you can write and explain basic OOP code, not just define terms.
  • Common mistake: Giving definitions only, or demonstrating 'encapsulation' with public fields.

Related Barclays questions

Collected from public candidate posts and coding forums. Updated Nov 2026.