Posts

Showing posts from December, 2022

Applet life cycle

  Applet Life Cycle in Java In Java, an  applet  is a special type of program embedded in the web page to generate dynamic content. Applet is a class in Java. The applet life cycle can be defined as the process of how the object is created, started, stopped, and destroyed during the entire execution of its application. It basically has five core methods namely init(), start(), stop(), paint() and destroy().These methods are invoked by the browser to execute. Along with the browser, the applet also works on the client side, thus having less processing time. Methods of Applet Life Cycle init():  The init() method is the first method to run that initializes the applet. It can be invoked only once at the time of initialization. The web browser creates the initialized objects, i.e., the web browser (after checking the security settings) runs the init() method within the applet. start():  The start() method contains the actual code of the applet and starts the applet....

Java Applet

  Java Applet Applet is a special type of program that is embedded in the webpage to generate the dynamic content. It runs inside the browser and works at client side. Advantage of Applet There are many advantages of applet. They are as follows: It works at client side so less response time. Secured It can be executed by browsers running under many plateforms, including Linux, Windows, Mac Os etc. Drawback of Applet Plugin is required at client browser to execute applet. Lifecycle of Java Applet Applet is initialized. Applet is started. Applet is painted. Applet is stopped. Applet is destroyed Lifecycle methods for Applet: The java.applet.Applet class 4 life cycle methods and java.awt.Component class provides 1 life cycle methods for an applet. java.applet.Applet class For creating any applet java.applet.Applet class must be inherited. It provides 4 life cycle methods of applet. public void init():  is used to initialized the Applet. It is invoked only once. public void start(...

Exceptions in Java

  Exceptions in Java The   Exception Handling in Java   is one of the powerful   mechanism to handle the runtime errors   so that the normal flow of the application can be maintained. In this tutorial, we will learn about Java exceptions, it's types, and the difference between checked and unchecked exceptions. Types of Java Exceptions There are mainly two types of exceptions: checked and unchecked. An error is considered as the unchecked exception. However, according to Oracle, there are three types of exceptions namely: Checked Exception Unchecked Exception Error Difference between Checked and Unchecked Exceptions 1) Checked Exception The classes that directly inherit the Throwable class except RuntimeException and Error are known as checked exceptions. For example, IOException, SQLException, etc. Checked exceptions are checked at compile-time. 2) Unchecked Exception The classes that inherit the RuntimeException are known as unchecked exceptions. For example, A...