An applet is a small program typically embedded within the web page which is used to create a dynamic and interactive application.Each applet that is created must be subclass of the Applet class, contained within the java.applet package. This class contains methods which govern the life and behavior of the Applet.
The built-in exceptions provided by the Java platform are used to handle errors occurring in the program. But , sometimes the programmer wants to create his own application specific exceptions. User defined exception can be created simply by defining a subclass of Exception class and using the throw keyword.
To build an applet, first of all we need to create an applet code(.java file). After successful compilation, its corresponding .class file is created. Then a web page also known as HTML document is to be developed. Once the HTML document is created, the applet is to be inserted in it. Finally the resultant HTML document will be executed to produce the desired output.
Java support Recursion function. Recursion is the attribute that allows a method to callitself. A method that calls itself is said to be recusive. The best example of recursion is the computation of the factorial(1*2*3*4*5) of a number. The factorial of a number n(any last number) is the product(*) of all the whole numbers between 1 and n.
So far, all of the variables used have been declared at the start of the main(). However, Java allows variables to be declared within any block. A block is begun with an opening braces and ended by a closing braces. A block defines a scope.
An Input Dialog Box is used to accept data from the user. It appears with a component like TextField, ComboBox or List which lets the user to input the data. It is created by using the static method showInputDialog() of JOptionPane.
The CardLayout manager is used to manage a large number of components. It organizes the components in layers which are arranged like a deck of cards sharing the same display area such only one of them is visible at a time. In order to use card layout, it is required to create an object of type JPanel that will hold the cards.
String is one of the special type of array that is array of characters. The term “String” generally means an ordered sequence of characters. In most programming language such string are enclosed in either single or double quotes.
Switch case is a multi way decision maker, that test whether an expression matches one of the number of values. In switch statement we use case, default, break reserved keywords.
Paint method allows you to draw a text message ,draw an image,draw a rectangle,oval etc. You can set the color of the text and the diagram(oval,rect,fillrect).