AJP 2 Marks
AJP 2 Marks
"A Java program can have many threads and these threads can run
concurrently, either asynchronously or synchronously.
INTRODUCTION
"Typically, we can define threads as a
lightweight subprocess and also has
separate paths of execution.
"Threads are independent, if there occurs 13
JLabel is a class in javax.swing package. JLabel is used to display a short message ie. String
or an image icon or both.
Example:
Lport javax. Swing. *;
public class Main extendsjavax . Swing.JErame (
publiC static void main (String args [] ) {
JFrame frame= new JFrame ("My Swing JLabel") ;
frame. setSize (400, 400) ;
JPanel panel = new JPanel () ;
JLabel heyImageLabel = neW JLabel () ;
We create a label named heylmageLabel with no text in it. To add an image to the label we
create an object of Imagelcon named heyimagelcon. It takes the address of the image as the
parameter. Using the setlcon method we add an icon to the label heylmageLabel as seen in
the output below.
Note: Here we use two backslashes instead of one and the png address should be in double
inverted commas.
OUTPUT:
EY!
Implementing Runnable interface
"The Runnable interface should be implemented by any class whose
instances are intended to be executed by a thread. Runnable
interface have only one method named run().
1. public void run(): is used to perform action for a thread.
"Starting a thread:
The start() method of Thread class is used to start a newly
created thread. t performs the following tasks:
"A new thread starts(with new callstack).
" The thread moves from New state to the Runnable state.
"When the thread gets a chance to execute, its target run() method
will run.
Demo for using ServletConfig (Contd.).
Web.xml
<web-app>
<servlet>
<servlet-name>Second</servlet-name>
<servlet-class>Second</servlet-class>
<init-param>
<param-name>homeName</param-narme>
<param-value>Welcome to www.simple.coms/param-value>
<linit-param>
<0servlet> The init parameter valuesre
<servlet-mapping> a configured in the
<servlet-name>Second</servlet-name> web.xml deployment
descriptor file
<url-pattern>/Second</ur-pattern>
<0servlet-mapping>
</web-app>
9
HashSet
Order
55-56/82
2. Active State
3. Waiting/Blocked State
4. Timed Waiting State
5. Terminated State
JDBC Drivers
10/202023
JDBC Application creation
steps to connect to database in Java
throw throws
24-25/93
An Example: LinkedList
Example: LinkedList
import java.util.*;
public class Test
|| Add to arrayList
for (int k=0; k< names. length; k++)
namelist.add(names[kl);