JAGANNATH INTERNATIONAL
MANAGEMENT SCHOOL
([Link] INFORMATION TECHNOLOGY)
(P-VII) Java LabSession:Feb2022-
June2022
BCA-252
SubmittedTo SubmittedBy:
[Link] Name:DIVYA MALIK
AssistantProfessor-IT 01814202020
JIMS,VASANTKUNJ
[Link]. NameofthePractical Date Signatur
e
1 Write down the steps to compile and run a
JavaProgram?
WriteaprogramtoprintHelloWorld.
Tostudythe basics of programming
a. Write a program to read name, age, phone
no,genderandCGPAfromuserandprintthevalue.
b. WAPtofindthelargestandsmallestof3numbersusi
ngifelse statement
c. Write a Java program that takes three
2 numbersas input to calculate and print the
average of thenumbers.
d. WAPtocalculateFactorial ofanumber
e. WAPtocheckwhetheragivennumberisArmstrong
or not
f. WAPtocheckleapyear.
g. WriteaJavaprogramthatcheckswhetheragiven
stringis a palindrome ornot.
3 WAP to display integer values of an array using
foreachloop.
4 WAPtoprintStringElementsinarrayusingforeachl
oop
5 WriteaJavaProgram toimplement arrayof objects.
6 WAP to read the array dynamically, sort the
arrayanddisplaythe sorted array.
7 WriteaJavaProgramto
demonstrateuseofnestedclass.
8 ProgramtofindAreaofcircle,RectangleandTria
ngleusingdifferentmethods
9 Javaprogramtodemonstrateexampleofstaticvar
iableand staticmethod.
10 WAPtoimplementSingleInheritance
11 WAPtoimplementMultilevelandHierarchyIn
heritance
12 WAPto createapackage in java
13 WAPto illustratetheconcept ofMethod Overriding
14 WAPtodemonstratetheconceptofAbstractClass
15 Write a program to demonstrate use of
implementinginterfaces.
16 Write a program to demonstrate use of
extendinginterfaces
17 Writeanprogramusingtry,catch,throwandfinally
18 WriteaprogramtoimplementtheconceptofExceptionHa
ndlingusingpredefined exception
19 WriteaprogramtoimplementtheconceptofExceptionH
andlingbycreatinguser-definedexceptions.
20 Writeaprogramtodemonstratethread priority.
21 WAPtoimplementtheconceptofMultithreading
22 WAPtodemonstrateMethodoverloading
23 WAPtoshowconstructoroverloading
24 Writeaprogram toimplementall stringoperations.
25 Writeaprogramtoimplementallstringoperationsusing
String Buffer Methods.
26 WAPtoreadthecontentsfromfileandwritingcontentsint
o a file
27 Developan appletthatdisplaysasimplemessage.
28 WriteaGUIProgramtoAddTwoNumbersUsingAWTa
nd event handling.
WAPtomakealoginGUIusingTextField,PasswordFiel
29 dandLoginButton usingSwings.
30 Write a java program that connects to a
databaseusing JDBC andperform add, delete and
retrieveoperations.
[Link] down the steps to compile and run a JavaProgram? Write a
program to print Hello World
CODE:
Step 1: Open a text editor, like Notepad on windows and TextEdit on Mac. And type
your first Program.
Step 2: Save the file as [Link].
Step 3: In this step, we will compile the program. For this, open command prompt
(cmd) on Windows
To compile the program, type the following command and hit enter.
javac [Link]
Step 4: After compilation the .java file gets translated into the .class file(byte code). Now
we can run the program. To run the program, type the following command and hit
enter:
java FirstJavaProgram
class HelloWorld {
public static void main(String[] args) {
[Link]("Hello, World!");
}
}
Q2. To study the basics of programming
a. Write a program to read name, age, phone no, gender and CGPA
from user and print the value.
b. WAP to find the largest and smallest of 3 number using ifelse
statement
c. Write a Java program that takes three numbers as input to calculate
and print the average of the numbers.
d. WAP to calculate Factorial of a number
e. WAP to check whether a given number is Armstrong or not
f. WAP to check leap year.
Write a Java program that checks whether a given string is a palindrome
or not.
CODE:
A)
import [Link];
public class CGPA {
public static void main(String[] args) {
String name;
int age;
Long phoneNum;
boolean gender;
double cgpa;
Scanner scanner = new Scanner([Link]);
[Link]("Enter name");
name = [Link]();
[Link]("Enter the age");
age = [Link]();
[Link]("Enter the phoneNum");
phoneNum = [Link]();
[Link]("Enter the gender");
gender = [Link]();
[Link]("Enter the cgpa");
cgpa = [Link]();
[Link](name);
[Link](age);
[Link](phoneNum);
[Link](gender);
[Link](cgpa);
}
}
B)
public class LarAndSmallest {
public static void main(String[] args) {
int fNum = 10;
int sNum = 24;
int tNum = 50;
if(fNum < sNum && fNum < tNum){
[Link](fNum + "is the smallest");
}else if(sNum<tNum){
[Link](sNum+ "is the smallest");
}else{
[Link](tNum + "is the smallest");
}
if(fNum > sNum && fNum > tNum){
[Link](fNum + "is the greatest");
}else if(sNum>tNum){
[Link](sNum+ "is the greatest");
}else{
[Link](tNum + "is the greatest");
}
}
}
C) import [Link];
public class AveNum {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int num1 = [Link]();
int num2 = [Link]();
int num3 = [Link]();
[Link]((num1+num2+num3)/3);
}
}
D) public class Factorial {
public static void main(String[] args) {
int num = 5;
int factorial = 1;
for(int i=1;i<=num; i++){
factorial = factorial * i;
}
[Link](factorial);
}
}
E)
public class ArmstrongOrNot {
public static void main(String[] args) {
int number = 1634, originalNumber, remainder, result = 0, n = 0;
originalNumber = number;
for (;originalNumber != 0; originalNumber /= 10, ++n);
originalNumber = number;
for (;originalNumber != 0; originalNumber /= 10){
remainder = originalNumber % 10;
result += [Link](remainder, n);
}
if(result == number)
[Link](number + " is an Armstrong number.");
else
[Link](number + " is not an Armstrong number.");
}
}
F)
public class LeapYear {
public static void main(String[] args) {
int year = 1996;
boolean leap = false;
// if the year is divided by 4
if (year % 4 == 0) {
// if the year is century
if (year % 100 == 0) {
// if year is divided by 400
// then it is a leap year
if (year % 400 == 0)
leap = true;
else
leap = false;
}
// if the year is not century
else
leap = true;
}
else
leap = false;
if (leap)
[Link](year + " is a leap year.");
else
[Link](year + " is not a leap year.");
}
}
G) import [Link];
public class PalindromeOrNot {
public static void main(String[] args) {
String str, rev = "";
Scanner sc = new Scanner([Link]);
[Link]("Enter a string:");
str = [Link]();
int length = [Link]();
for ( int i = length - 1; i >= 0; i-- )
rev = rev + [Link](i);
if ([Link](rev))
[Link](str+" is a palindrome");
else
[Link](str+" is not a palindrome");
}
}
Q3. WAP to display integer values of an array using for each loop and print
String Element in array using for each loop
CODE:
public class ForEachLoop {
public static void main(String[] args) {
int arr[]= {1,2,3,4};
for (int i : arr){
[Link](i);
}
}
}
CODE:
public class Ques4 {
public static void main(String[] args) {
String arr[]= {"apple", "banana", "jackfruit"};
for (String i : arr){
[Link](i);
}
}}
[Link] to read the array dynamically, sort the array and display the
sorted array.
CODE:
import [Link];
public class Ques6 {
public static void main(String[] args) {
int arr[] = {2,4,5,6};
[Link](arr);
[Link]("Sorted Array" + [Link](arr));
}
}
[Link] Program to demonstrate use of nested class.
CODE:
public class Ques7 {
public static void main(String[] args) {
ParentClass pc = new ParentClass();
[Link] cc = new [Link]();
}
}
class ParentClass{
ParentClass(){
[Link]("Parent class got called");
}
public static class ChildClass{
ChildClass(){
[Link]("Child class got called");
}
}
}
[Link] program to demonstrate example of static variable and static
method.
CODE:
public class Ques9 {
public static void main(String[] args) {
[Link]([Link](5));
}
}
class calculation
{
static double pi = 3.14;
public static double areaOfCircle(int radius){
return pi*radius*radius;
}
}
Q7. WAP to implement Single Inheritance
CODE:
public class Ques10 {
public static void main(String[] args) {
BClass bc = new BClass();
}
}
class PClass{
static int money = 500000;
}
class BClass extends PClass{
BClass(){
[Link]("MONEY IS: " + money);
}}
Q8. WAP to implement Multilevel and Hierarchy Inheritance
CODE:
public class Ques11 {
public static void main(String[] args) {
bClass bc = new bClass();
[Link]("\n\n");
PClass pc = new PClass();
mClass mc = new mClass();
}
}
interface dClass{
int money = 1000000;
}
class PClass implements dClass {
PClass(){
[Link]("D money is p money: "+ money+ "using hierarchical
inheritance");
}
}
class bClass extends PClass{
bClass(){
[Link]("p money is b money: "+ money+ " with multilevel inheritance
");
}
}
class mClass implements dClass{
mClass(){
[Link]("d money is m money: " + money + "using hierarchical
inheritance");
}
Q9. WAP to create a package in java
CODE:
package data;
// Class to which the above package belongs
public class Demo {
// Member functions of the class- 'Demo'
// Method 1 - To show()
public void show()
{
// Print message
[Link]("Hi Everyone");
}
// Method 2 - To show()
public void view()
{
// Print message
[Link]("Hello");
}
}
import data.*;
// Class to which the package belongs
class ncj {
// main driver method
public static void main(String arg[])
{
// Creating an object of Demo class
Demo d = new Demo();
// Calling the functions show() and view()
// using the object of Demo class
[Link]();
[Link]();
}
}
Q10. WAP to illustrate the concept of Method Overriding
CODE:
public class Ques13 {
public static void main(String[] args) {
childClass cc = new childClass();
childClass cc1 = new childClass(1);
[Link]();
}
}
class ppClass{
ppClass(){
[Link]("Parent constructor got called");
}
public void attribute(){
[Link]("Parent method called using method overriding");
}
}
class childClass extends ppClass{
childClass(int i){
[Link]("Constructor overriding with params");
}
public void attribute(){
[Link]();
[Link]("Child method called");
}
childClass(){
[Link]("Child constructor got called");
}
}
Q11. Write a program using try,catch,throw and finally
CODE:
public class Ques17 {
public static void main(String[] args) throws Exception {
try{
int arr[] = {12,3,4};
[Link](arr[5]);
}catch (Exception e){
[Link](e);
}
finally {
[Link]("Error catched finally");
}
try{
throw new Exception("MyCreatedException");
}
catch (Exception e2){
[Link](e2);
}
}
}
Q12. WAP to demonstrate the concept of Abstract Class
CODE:
import [Link].*;
abstract class shape
{
int x,y;
abstract void area(double x,double y);
}
class Rectangle extends shape
{
void area(double x,double y)
{
[Link]("Area of rectangle is :"+(x*y));
}
}
class Circle extends shape
{
void area(double x,double y)
{
[Link]("Area of circle is :"+(3.14*x*x));
}
}
class Triangle extends shape
{
void area(double x,double y)
{
[Link]("Area of triangle is :"+(0.5*x*y));
}
}
public class AbstractDemo
{
public static void main(String[] args)
{
[Link]("DIVYA MALIK-01814202020");
Rectangle r=new Rectangle();
[Link](2,5);
Circle c=new Circle();
[Link](5,5);
Triangle t=new Triangle();
[Link](2,5);}}
Q13. Write a program to demonstrate use of implementing interfaces
CODE:
interface Drawable{
void draw();
}
class Rectangle implements Drawable{
public void draw(){[Link]("Drawing Rectangle");}
}
class Circle implements Drawable{
public void draw(){[Link]("Drawing Circle");}
}
public class interfaceprog{
public static void main(String args[]){
[Link]("DIVYA MALIK-01814202020");
Drawable d=new Circle();
[Link]();
}}
Q14. Write a program to implement the concept of Exception Handling
using predefined exception and user defined exception.
A) Predefined Exception-:
CODE:
public class PredefinedException {
public static void main(String args[])
{
int positive = 35;
int zero = 0;
int result = positive/zero;
//Give Unchecked Exception here.
[Link](result);
}
}
B) User Defined Exception
class InvalidAgeException extends Exception
{
public InvalidAgeException (String str)
{
// calling the constructor of parent Exception
super(str);
}
}
// class that uses custom exception InvalidAgeException
public class UserExceptionMarriage
{
// method to check the age
static void validate (int age) throws InvalidAgeException{
if(age < 18){
// throw an object of user defined exception
throw new InvalidAgeException("age is not valid to vote");
}
else {
[Link]("welcome to vote");
}
}
// main method
public static void main(String args[])
{
try
{
// calling the method
validate(16);
}
catch (InvalidAgeException ex)
{
[Link]("Caught the exception");
// printing the message from InvalidAgeException object
[Link]("Exception occured: " + ex);
}
[Link]("rest of the code...");
}
}
Q15. Write a program to demonstrate thread priority.
CODE:
public class threadpriority implements Runnable {
public void run() {
[Link]([Link]()); // This method is static.
}
public static void main(String[] args) {
threadpriority a = new threadpriority();
Thread t = new Thread(a, "DIVYA MALIK-01814202020");
[Link]("Priority of Thread: " + [Link]());
[Link]("Name of Thread: " + [Link]());
[Link]();
}
}
Q16. WAP to Check the Thread Status using multithreading
CODE:
import [Link];
class MyThread implements Runnable {
public void run() {
try {
[Link](2000);
} catch (Exception err) {
[Link](err);
}
}
}
public class threadstatus {
public static void main(String args[]) throws Exception {
[Link]("\nMADEBY:DIVYA MALIK-01814202020\n");
for (int thread_num = 0; thread_num< 5; thread_num++) {
Thread t = new Thread(new MyThread());
[Link]("MyThread:" + thread_num);
[Link]();
}
Set<Thread>threadSet = [Link]().keySet();
for (Thread t :threadSet) {
[Link]("Thread :" + t + ":"
+ "Thread status : "
+ [Link]());
}
}
}
Q17. WAP to implement the concept of Multithreading
CODE:
public class MultiThreading {
public static void main (String args[]) {
//try block
try
{
[Link] ("::Try Block::");
int data = 125 / 5;
[Link] ("Result:" + data);
throw new ArithmeticException(null);
}
//catch block
catch (NullPointerException e) {
[Link] ("::Catch Block::");
[Link] (e);
}
//finally block
finally {
[Link] (":: Finally Block::");
[Link] ("No Exception::finally block executed");
}
[Link] ("rest of the code...");
}
}
Q18. Write a program to implement all string operations.
CODE:
public class stringoperations {
public static void main(String args[]) {
[Link]("Made By:DIVYA MALIK-01814202020");
String s1 = "Hello";
String s2 = "World";
[Link]("The strings are " + s1 + "and" + s2);
int len1 = [Link]();
int len2 = [Link]();
[Link]("The length of " + s1 + " is :" + len1);
[Link]("The length of " + s2 + " is :" + len2);
[Link]("The concatenation of two strings = " + [Link](s2));
[Link]("First character of " + s1 + "is=" + [Link](0));
[Link]("The uppercase of " + s1 + "is=" + [Link]());
[Link]("The lower case of " + s2 + "is=" + [Link]());
[Link](" the letter e occurs at position" + [Link]("e") + "in" + s1);
[Link]("Substring of " + s1 + "starting from index 2 and ending at 4 is =" +
[Link](2, 4));
[Link]("Replacing 'e' with 'o' in " + s1 + "is =" + [Link]('e', 'o'));
boolean check = [Link](s2);
if (check == false)
[Link]("" + s1 + " and " + s2 + " are not same");
else
[Link]("" + s1 + " and " + s2 + "are same");
}
}
Q19. Write a program to implement all string operation using String
Buffer Methods.
CODE:
public class stringbuffer
{
public static void main( String args[] )
{
StringBuffer s = new StringBuffer("DIVYA MALIK");
[Link]("\n String = "+s); // Will Print the string
[Link]("\n Length = "+[Link]() ); // total numbers of characters
[Link]("\n Length = "+[Link]() ); // total allocated capacity
[Link](6); // Sets the length and destroy the remaining characters
[Link]("\n After setting length String = "+s );
[Link](0,'K'); // It will change character at specified position
[Link]("\n SetCharAt String = "+s );
[Link](0,'C');
int a = 007;
[Link](a); // It concatenates the other data type value
[Link]("\n Appended String = "+s );
[Link](6," BCA"); // used to insert one string or char or object
[Link]("\n Inserted String = "+s );
[Link]();
[Link]("\n Reverse String = "+s );
[Link]();
[Link](6,14); // used to delete sequence of character
[Link]("\nAfter deleting string="+s);
}
}
Q20. . WAP to read the contents from file and writing contents into a file.
CODE:
import [Link].*;
public class readandwrite {
public static void main(String arg[]) {
File inf = new File("[Link]");
File outf = new File("[Link]");
FileReader ins = null;
FileWriter outs = null;
try {
ins = new FileReader(inf);
outs = new FileWriter(outf);
int ch;
while ((ch = [Link]()) != -1) {
[Link](ch);
}
} catch (IOException e) {
[Link](e);
[Link](-1);
} finally {
try {
[Link]();
[Link]();
} catch (IOException e) {
}
}
}
}
Q21. WAP to display user registration form using applet
CODE:
[Link]
import [Link].*;
public class userregistration extends [Link]
{
public void init()
{
setLayout(new FlowLayout([Link]));
add(new Label("Name :"));
add(new TextField(10));
add(new Label("Address :"));
add(new TextField(10));
add(new Label("Birthday :"));
add(new TextField(10));
add(new Label("Gender :"));
Choice gender = new Choice();
[Link]("Man");
[Link]("Woman");
Component add = add(gender);
add(new Label("Job :"));
CheckboxGroup job = new CheckboxGroup();
add(new Checkbox("Student", job, false));
add(new Checkbox("Teacher", job, false));
add(new Button("Register"));
add(new Button("Exit"));
}
}
[Link]
<html>
<head><title>Register</title></head>
<body>
<applet code="[Link]" width=230 height=300></applet>
</body>
</html>
Q22. WAP to explain important fields of AWT.
CODE:
Q23. WAP to explain important fields of event handling.
CODE:
import [Link].*;
import [Link].*;
public class eventhandling extends Frame implements ActionListener
{
TextFieldtextField;
eventhandling ()
{
textField = new TextField ();
[Link] (60, 50, 170, 20);
Button button = new Button ("Show");
[Link] (90, 140, 75, 40);
[Link] (this);
add (button);
add (textField);
setSize (250, 250);
setLayout (null);
setVisible (true);
}
public void actionPerformed (ActionEvent e)
{
[Link] ("Hello World");
}
public static void main (String args[])
{
new eventhandling();
}
}
Q24. Objective:Write a GUI Program to Add Two numbers Using AWT
and event handling.
CODE:
import [Link].*;
import [Link].*;
import [Link].*;
public class Users extends Applet implements ActionListener
{
TextField t1 = new TextField(8);
TextField t2 = new TextField(8);
TextField t3 = new TextField(8);
Label l1 = new Label("FIRST NO :");
Label l2 = new Label("SECOND NO :");
Label l3 = new Label("SUM :");
Button b = new Button("ADD");
public void init()
{
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(b);
[Link](this);
}
public void actionPerformed(ActionEvent e)
{
if([Link]() == b)
{
int n1 = [Link]([Link]());
int n2 = [Link]([Link]());
[Link](" " +(n1 + n2));
}
}
}
Q25. WAP to show database connection is established.
CODE:
import [Link].*;
public class testconn{
public static void main(String args[]){
try{
[Link]("[Link]");
Connection con=[Link](
"jdbc:mysql://localhost:3306/Persons","root","");
Statement stmt=[Link]();
[Link](" Connection established");
ResultSetrs=[Link]("select * from BOOKS");
while([Link]())
[Link]([Link](1)+" "+[Link](2)+" "+[Link](3)+" "
+[Link](4)+" "+ [Link](5)+" ");
[Link]();
}catch(Exception e){ [Link](e);} }}
Q26. WAP to make a login GUI using TextField, Password Field and Login
Button using Swings.
CODE:
import [Link].*;
import [Link].*;
import [Link];
import [Link];
class LoginFrame extends JFrame implements ActionListener {
Container container = getContentPane();
JLabeluserLabel = new JLabel("USERNAME");
JLabelpasswordLabel = new JLabel("PASSWORD");
JTextFielduserTextField = new JTextField();
JPasswordFieldpasswordField = new JPasswordField();
JButtonloginButton = new JButton("LOGIN");
JButtonresetButton = new JButton("RESET");
JCheckBoxshowPassword = new JCheckBox("Show Password");
LoginFrame() {
setLayoutManager();
setLocationAndSize();
addComponentsToContainer();
addActionEvent();
public void setLayoutManager() {
[Link](null);
}
public void setLocationAndSize() {
[Link](50, 150, 100, 30);
[Link](50, 220, 100, 30);
[Link](150, 150, 150, 30);
[Link](150, 220, 150, 30);
[Link](150, 250, 150, 30);
[Link](50, 300, 100, 30);
[Link](200, 300, 100, 30);
public void addComponentsToContainer() {
[Link](userLabel);
[Link](passwordLabel);
[Link](userTextField);
[Link](passwordField);
[Link](showPassword);
[Link](loginButton);
[Link](resetButton);
}
public void addActionEvent() {
[Link](this);
[Link](this);
[Link](this);
}
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == loginButton) {
String userText;
String pwdText;
userText = [Link]();
pwdText = [Link]();
if ([Link]("mrinal")
&&[Link]("12345")) {
[Link](this, "Login Successful");
} else {
[Link](this, "Invalid Username or Password");
}
}
if ([Link]() == resetButton) {
[Link]("");
[Link]("");
}
if ([Link]() == showPassword) {
if ([Link]()) {
[Link]((char) 0);
} else {
[Link]('*');
}
}
}
}
public class Login {
public static void main(String[] a) {
[Link]("Made By:Mrinal Gupta(033)");
LoginFrame frame = new LoginFrame();
[Link]("Login Form");
[Link](true);
[Link](10, 10, 370, 600);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](false);
}
Q27. WAP to explain servlet concept.
CODE:
import [Link].*;
import [Link].*;
import [Link].*;
public class DemoServlet extends HttpServlet{
public void doGet(HttpServletRequestreq,HttpServletResponse res)
throws ServletException,IOException
{
[Link]("text/html");
PrintWriter pw=[Link]();
[Link]("<html><body>");
[Link]("Welcome to servlet");
[Link]("</body></html>");
[Link]();
}}
[Link] file
<web-app>
<servlet>
<servlet-name>sonoojaiswal</servlet-name>
<servlet-class>DemoServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sonoojaiswal</servlet-name>
<url-pattern>/welcome</url-pattern>
</servlet-mapping>
</web-app>
Q28. WAP to display data of database using jdbc.
CODE:
import [Link].*;
public class PersonsJDBC{
public static void main(String args[]){
try{
[Link]("[Link]");
Connection con=[Link](
"jdbc:mysql://localhost:3306/Persons","root","");
Statement stmt=[Link]();
ResultSetrs=[Link]("select * from BOOKS");
while([Link]())
[Link]([Link](1)+" "+[Link](2)+" "+[Link](3)+" "
+[Link](4)+" "+ [Link](5)+" ");
[Link]();
}catch(Exception e){ [Link](e);}
}}
Q30. Write a java program that connects to a database using JDBC and
does add, delete and retrieve operations.
CODE:
import [Link].*;
public class UpdateJDBC{
public static void main(String args[]){
try{
[Link]("[Link]");
Connection con=[Link](
"jdbc:mysql://localhost:3306/Persons","root","");
Statement stmt=[Link]();
[Link]("Database");
ResultSet rs2=[Link]("select * from BOOKS");
while([Link]())
[Link]([Link](1)+" "+[Link](2)+" "+[Link](3)+" "
+[Link](4)+" "+ [Link](5)+" ");
[Link]("\n\n");
String sqlInsert = "insert into books values (3001, 'Gone Fishing', 'Kumar', 11.11, 11)";
[Link]("The SQL statement is: " + sqlInsert + "\n"); // Echo for debugging
int countInserted= [Link](sqlInsert);
[Link](countInserted + " records inserted.\n");
[Link]("Database after insertion");
ResultSetrs=[Link]("select * from BOOKS");
while([Link]())
[Link]([Link](1)+" "+[Link](2)+" "+[Link](3)+" "
+[Link](4)+" "+ [Link](5)+" ");
[Link]("\n\n");
String sqlDelete = "delete from books where id >= 3000 and id < 4000";
[Link]("The SQL statement is: " + sqlDelete + "\n"); // Echo for debugging
int countDeleted =[Link](sqlDelete);
[Link](countDeleted + " records deleted.\n");
[Link]("Database after deletion");
ResultSet rs1=[Link]("select * from BOOKS");
while([Link]())
[Link]([Link](1)+" "+[Link](2)+" "+[Link](3)+" "
+[Link](4)+" "+ [Link](5)+" ");
[Link]("\n\n");
[Link]();
}catch(Exception e){ [Link](e);}
}
}