๐—๐—ฎ๐˜ƒ๐—ฎ ๐—”๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€ ๐— ๐—ผ๐—ฑ๐—ถ๐—ณ๐—ถ๐—ฒ๐—ฟ๐˜€ ๐—ณ๐—ผ๐—ฟ ๐—•๐—ฒ๐—ด๐—ถ๐—ป๐—ป๐—ฒ๐—ฟ๐˜€

Access modifiers control who sees your code. They keep your programs safe and organized.

You have four types in Java:

Look at this example. You have two packages: salem and madurai.

The Parent class lives in salem. It has a public pin and protected methods.

A Child class in the same package accesses public and protected items.

A Child class in a different package accesses public and protected items through inheritance.

Here is how access works:

Source: https://dev.to/vinayagam_6a170db9281d526/access-modifiers-in-java-explained-for-beginners-121h