The wallet is stored in a Berkeley database file (BDB) (usually ~/.litecoin/wallets/wallet.dat). Litecoin Core can use either BDB 4.8, 5.x or 6.x to create and access the wallet file. Wallets created using BDB 4.8 are also accessible by BDB 5.x and 6.x. Wallets created using BDB 5.x or 6.x are not accessible by BDB 4.8. Opening and using a wallet created by 4.8 with a higher major version (5.x or 6.x) does not change its format, so it will still be accessible to 4.8 afterwards. But encrypting an unencrypted wallet recreates it, so encrypting a 4.8 wallet with Litecoin Core linked against BDB 5.x or 6.x will render it unreadable for Litecoin Core linked against BDB 4.8. If you do not plan on copying the wallet file to another machine that uses BDB 4.8 then it is recommended to use the modern versions of BDB 5.x or 6.x.