Whenever we face an anomaly during the usual process of execution of a Java program, the anomaly is called an Exception. A lot of times, even if the program has compiled successfully, at runtime, an error can be thrown because of something that comes up during the dynamic phase of a program. Now, there are two ways that the program can deal with an Exception preemptively, throwing an error or catching the error and executing a failsafe snippet of code instead. This way, the program will still execute entirely without stopping at the part where the exception is found.
These methods of dealing with Exceptions come under Exception Handling which is a very critical aspect to understand if you're looking to learn java.