Correct me if I'm mistaken, but I read somewhere the payment id can be public on the blockchain or it can be hidden by having it encoded into the address? Is there an example transaction that has the payment id public?
There are two kinds of payment ids: plaintext ones, and encrypted ones.
Plaintext ones can be viewed in a block explorer, and one such example is found in block 1412534, transaction 2fbf1e227847b9bf604aee0e567531196214f8dae9dbc687f1e70bef4cf4ea67:
You can see this transaction included a plaintext payment id: dc4a15c532e88c5dd8411b6f9b41ec42b2c9f64e8c583c98feba2073116910d4
How these are interpreted is up to the receiver. It could be a key in a database, a hash of some information, a simple counter, etc. Some payment IDs have also been used to embedded "funny comments" in transactions. See for example https://xmrchain.net/search?value=19ee085a00ee7fd642709a14bbf74f36de5a890c32eff75fdacb8ff26a826b93 found by JollyMort below (666c75666679706f6e7920697320746865206265737420706f6e792065766572 is the hexadecimal representation of "fluffypony is the best pony ever", fluffypony being the Monero maintainer at this time).
As for encrypted payment ids, only the recipient can decrypt them. These are short form, and are mostly used along with integrated addresses, which are a convenient "bundle" carrying both the address and such a payment id.