Experiment No.
Program Name: Write HTML/Java scripts to display your CV in navigator, your
Institute website, Department Website and Tutorial website for specific
subject.
Theory Concepts: Use of HTML tags and CSS to develop resume.
Implementation:
<html>
<head>
<title>Rani</title>
<style>
body, td, p, li {
font-family: "Times New Roman";
font-size: 12.0pt;
}
table {
width: 70%;
border-collapse: collapse;
margin: auto; /* centers the table */
}
ul {
margin-top: 0;
margin-bottom: 0;
padding-left: 20px; /* standard indentation for bullets */
}
.center-text {
text-align: center;
}
.email-link {
color: blue;
text-decoration: none;
}
</style>
</head>
<body>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="26" class="center-text"><b><font size="5">Rani</font></b></td>
</tr>
<tr>
<td height="17" class="center-text">House -489 , ghaziabad </td>
</tr>
<tr>
<td height="17" class="center-text">Ajay Kumar Garg Engineering College,
Ghaziabad (U.P.)-201009.</td>
</tr>
<tr>
<td height="17" class="center-text">Contact No.:- +918076083343</td>
</tr>
<tr>
<td height="17" class="center-text">E-mail:-<a
href="[Link]
class="email-link">rani7042003@[Link]</a></td>
</tr>
<tr>
<td height="19"> </td>
</tr>
<tr>
<td bgcolor="#808080" height="20" class="center-text"><b><font
size="4">Objectives</font></b></td>
</tr>
<tr>
<td height="38">
<p>To work in a challenging and motivating environment where I can use my
potential to the very best and work towards refining my technical skills, knowledge and
personality.</p>
</td>
</tr>
<tr>
<td height="19"> </td>
</tr>
<tr>
<td bgcolor="#808080" height="20" class="center-text"><b><font
size="4">Qualification</font></b></td>
</tr>
<tr>
<td>
<ul>
<li>Pursuing Bachelor of Technology (Computer Science and Engineering) from
Ajay Kumar Garg Engineering College, Ghaziabad. Uttar Pradesh Technical University,
Luckhnow. Aggregate Percentage till 5<sup>th</sup> semester 9.22.</li>
<li>Intermediate with 91% from Children’s Academy School,Ghaziabad (CBSE
Board) in 2021.</li>
<li>High School with 92.4% from Chilren's Academy, Ghaziabad(CBSE Board) in
2019.</li>
</ul>
</td>
</tr>
</table>
</div>
</body>
</html>
Output:
Experiment No.2
Program Name: Write an HTML program to design an entry form of student
details and send it to store at database server like SQL, Oracle or MS Access.
Theory Concepts: Use basic HTML tags to develop all programs and JDBC
connectivity.
Implementation:
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pet Details</title>
<style>
label {
display: block;
margin: 10px 0 5px;
}
input[type="text"], input[type="submit"] {
margin-bottom: 10px;
}
</style>
</head>
<body>
<form name="petDetails" method="post" action="SavePetDetails1">
<fieldset>
<legend>Enter pet details</legend>
<label for="name">Name:</label>
<input type="text" name="name" id="name">
<label for="owner">Owner:</label>
<input type="text" name="owner" id="owner">
<label for="species">Species:</label>
<input type="text" name="species" id="species">
<label for="sex">Sex:</label>
<input type="text" name="sex" id="sex">
<label for="birth">Birth:</label>
<input type="text" name="birth" id="birth">
<label for="death">Death (optional):</label>
<input type="text" name="death" id="death">
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class SaveDetails {
public void saveDetails(String name, String owner, String species, String sex, String birth,
String death) {
try {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
[Link] bdateStr = [Link](birth);
[Link] bdateDB = new [Link]([Link]());
[Link] ddateStr = [Link](death);
[Link] ddateDB = new [Link]([Link]());
[Link]("[Link]");
Connection con = [Link]("jdbc:mysql://localhost:3306/db1?
autoReconnect=true&useSSL=false", "root", "root");
String insString = "INSERT INTO [Link] VALUES (?,?,?,?,?,?)";
PreparedStatement insStmt = [Link](insString);
[Link](1, name);
[Link](2, owner);
[Link](3, species);
[Link](4, sex);
[Link](5, bdateDB);
[Link](6, ddateDB);
[Link]();
[Link]();
[Link]("Statement executed successfully.");
} catch (ParseException | ClassNotFoundException | SQLException e) {
[Link](e);
}
}
}
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class SaveDetails {
public void saveDetails(String name, String owner, String species, String sex, String birth,
String death) {
try {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
[Link] bdateStr = [Link](birth);
[Link] bdateDB = new [Link]([Link]());
[Link] ddateStr = [Link](death);
[Link] ddateDB = new [Link]([Link]());
[Link]("[Link]");
Connection con = [Link]("jdbc:mysql://localhost:3306/db1?
autoReconnect=true&useSSL=false", "root", "root");
String insString = "INSERT INTO [Link] VALUES (?,?,?,?,?,?)";
PreparedStatement insStmt = [Link](insString);
[Link](1, name);
[Link](2, owner);
[Link](3, species);
[Link](4, sex);
[Link](5, bdateDB);
[Link](6, ddateDB);
[Link]();
[Link]();
[Link]("Statement executed successfully.");
} catch (ParseException | ClassNotFoundException | SQLException e) {
[Link](e);
}
}
}
Output / Conclusion:
Step 1: After entering the data on the Pet form
Step 2: After clicking on Submit Query and the data saved successfully,
following page is displayed.
Experiment No.3
Program Name: Write programs using Java script for Web Page to display
browsers information.
Theory Concepts: Java script helps to access browser information.
Implementation:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Browser Information</title>
<script>
function show() {
[Link]("Name: " + [Link] + "<br>");
[Link]("Version: " + [Link] + "<br>");
[Link]("Codename: " + [Link] + "<br>");
[Link]("Cookies Enabled: " + [Link] + "<br>");
[Link]("Java Enabled: " + [Link]() + "<br>"); // Added () for
method call
[Link]("MIME Types: " + [Link] + "<br>"); // Corrected
to show count
[Link]("Platform: " + [Link] + "<br>");
[Link]("Plugins: " + [Link] + "<br>"); // Corrected to show
count
[Link]("System Language: " + [Link] + "<br>"); // Note:
systemLanguage is deprecated
[Link]("User Agent: " + [Link] + "<br>"); // Corrected label
duplication
}
</script>
</head>
<body>
<form id="form1">
<div>
<input id="Button1" type="button" value="Click me" onclick="show()" />
</div>
</form>
</body>
</html>
Output / Conclusion:
Save the above program as .html file and when user clicks on show following
page is displayed
Experiment No. 4
Program Name: Write a program in Java to allot rooms in the hostel using
Inheritance. Incorporate method overloading and method overriding concepts
in the program.
Theory Concepts: Overloading: In same class, if name of the method remains
common but the number and type of parameters are different, then it is called
method overloading in [Link]: A method is said to be overridden
when one is in parent class and another is in child class with the same name,
same return type, and same parameter.
Inheritance :
Single level inheritance e.g. (class B extends Class A).
Multilevel inheritance e.g. (class C extends class B and class B extends Class A).
Multiple inheritance is not possible in JAVA.
Implementation:
1. Base abstract class Room
public abstract class Room {
private int room_no;
booleanalotted;
public int getRoom_no()
{ return room_no;
}
public void setRoom_no(int rm)
{ this.room_no=rm; }
public booleangetAlotted()
{
return alotted;
}
public void setAlloted(boolean allot)
{
[Link]=allot;
}
public booleanallotRoom(String[] allotee)
{ return true;
}
public booleanallotRoom(String allotee)
{ return true;
}}
2. Class SingleBedRoom
public class SingleBedRoom extends Room{
private String allotedTo;
public booleanallotRoom(String allotee)
{ setAllotedTo(allotee);
[Link]("Room allotted successfully");
return true;
}
public void setAllotedTo(String allotee)
{
[Link]=allotee;
}}
3. Class DoubleBedRoom
public class DoubleBedRoom extends Room{
private String allotedTo;
public booleanallotRoom(String[] allotee)
{ [Link]("Room allotted successfully");
for(int i=0;i<[Link];i++)
{
setAllotedTo(allotee[i]);
}
[Link]("Room allotted successfully");
return true;
}
public void setAllotedTo(String allotee)
{
[Link]=allotee;
}
}
4. Class RoomReserve
public class RoomReserve {
public static void main(String[] args)
{
Scanner userInput =new Scanner([Link]) ;
[Link]("Which type of room do you want to reserve");
String roomType = [Link]();
if([Link]("Single"))
{
Room singleBed= new SingleBedRoom();
[Link]("Enter the name of person");
String userName=[Link]();
[Link](userName);
}
else
{
Room doubleBed= new DoubleBedRoom();
[Link]("Enter the name of persons");
String userName=[Link]();
[Link](userName);
}
[Link]();
}}
Output / Conclusion:
When user enters room type as Single, single bedroom is reserved
Experiment No. 5
Program Name: Develop a program in Java to run three threads of the program
simultaneously using multithreading. Include try, catch block in the program.
Theory Concepts: Create a class which implements Runnable interface. Create
three threads for the implemented class’s object and observe their behavior.
Implementation:
public class T1 implements Runnable {
public void run() {
try {
for(int n = 5; n > 0; n--) {
Thread t = [Link]();
String name = [Link]();
[Link]("name=" + name +n);[Link](1000);
}
} catch (InterruptedException e) {
[Link]("Child thread interrupted");
}
}
public static void main(String args[]) {
try { T1 a1 =new T1();
Thread t1 = new Thread(a1, "First Thread"); [Link]();
T1 a2 =new T1();
Thread t2 = new Thread(a2, "Second Thread"); [Link]();
T1 a3 =new T1();
Thread t3 = new Thread(a3, "Third Thread"); [Link]();
for(int n = 5; n > 0; n--) {
[Link]("main thread "+n);
[Link](1000);
}
} catch (InterruptedException e) {
[Link]("Main thread interrupted");
}}}
Output / Conclusion: The threads will execute the run method simultaneously.
Experiment No. 6
Program Name: Write a Java applet to display the Application Program
screen i.e. calculator and other.
Theory Concepts:[Link] class is used to create a user defined
applet.
Implementation:
import [Link].*;
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
public class calculator extends Applet implements ActionListener, TextListener
{
String s,s1,s2,s3,s4;
Button b1,b2,b3,b4,b5,b6,b7,b8,b9,b0;
Button add,sub,eq,cl,mul,div;
TextField t1;
int a,b,c;
public void init()
{
t1=new TextField(10);
b1=new Button("1");
b2=new Button("2");
b3=new Button("3");
b4=new Button("4");
b5=new Button("5");
b6=new Button("6");
b7=new Button("7");
b8=new Button("8");
b9=new Button("9");
b0=new Button("0");
add=new Button("+");
sub=new Button("-");
mul=new Button("*");
div=new Button("/");
eq=new Button("=");
cl=new Button("Clear");
GridLayoutgb=new GridLayout(4,5);
setLayout(gb);
add(t1);
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(b6);
add(b7);
add(b8);
add(b9);
add(b0);
add(add);
add(sub);
add(mul);
add(div);
add(eq);
add(cl);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
paint();
//[Link](this);
}
public void paint()
{
setBackground([Link]);
}
public void actionPerformed(ActionEvent e)
{
s=[Link]();
if([Link]("0")||[Link]("1")||[Link]("2")|| [Link]("3")||[Link]("4")||
[Link]("5")||[Link]("6")||[Link]("7")||[Link]("8")|| [Link]("9")||[Link]("0"))
{
s1=[Link]()+s;
[Link](s1);
} if([Link]("+"))
{
s2=[Link]();
[Link]("");
s3="+";
}
if([Link]("-"))
{
s2=[Link]();
[Link]("");
s3="-";
}
if([Link]("*"))
{
s2=[Link]();
[Link]("");
s3="*";
}
if([Link]("*"))
{
s2=[Link]();
[Link]("");
s3="*";
}
if([Link]("=")) {
s4=[Link]();
a=[Link](s2);
b=[Link](s4);
if([Link]("+")) c=a+b;
if([Link]("-")) c=a-b;
[Link]([Link](c));
}
if([Link]("Clear"))
{
[Link]("");
}}
public void textValueChanged(TextEvent e) { } }
Output / Conclusion:
Experiment No. 7
Program Name: Writing program in XML for creation of DTD, which specifies set of rules.
Create a style sheet in CSS/ XSL & display the document in internet explorer.
Theory Concepts: An XML file is created with DTD. A style sheet in CSS format is also
created for that XML file. XML With DTD and CSS files are combined together to check the
output on browser’s screen.
Implementation:
1. XML With DTD
<?xml version=”1.0”?>
<!DOCTYPE note[
<!ELEMENT note(to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading(#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Simran</to>
<from> Rani</from>
<heading>Reminder </heading>
</body>Don't forget me this weekend</body>
</note>
2. CSS for XML
products {font-size:80%; margin:0.5em; font-family: Verdana; display:block}
product {display:block; border: 1px solid silver; margin:0.5em; padding:0.5em; background-
color:whitesmoke;}
name, price, stock, country {display:block}
name {color:red; text-decoration: underline}
price {color:green}
stock {color:brown}
country {color:blue}
/* IE supports the ID selector also for XML */
product#p4 {text-align:right}
/* Alternative in: Firefox, Opera, Google Chrome * /
product[id=p4] {text-align:right}
/* IE supports the class attribute for XML */
[Link] {background-color:mistyrose}
/* Alternative in: Firefox, Opera, Google Chrome */
product[class=special] {background-color:mistyrose}
3. XML With CSS
<?xml version=”1.0” encoding=”UTF-8”?>
<?xml-stylesheet type=”text/css” href=”[Link]”?>
<products>
<product id=”p1” class=”special”>
<name>Delta</name>
<price>800</price>
<stock>4</stock>
<country>Denmark</country>
</product>
<product id=”p2”>
<name>Golf</name>
<price>1000</price>
<stock>5</stock>
<country>Australia</country>
</product>
<product id=”p5” class=”special”>
<name>Tango</name>
<price>1225</price>
<stock>3</stock>
<country>Japan</country>
</product>
</products>
Output/Conclusion:
Experiment No. 8
Program Name: Program to illustrate JDBC connectivity. Program for
maintaining database by sending queries. Design and implement a simple
Servlet book query with the help of JDBC & SQL. Create MS Access Database,
Create on ODBC link, Compile & execute JAVA JDVC Socket.
Theory Concepts:Java DataBase Connectivity is used to connect Java to
Database. [Link] () method register the database driver to JDBC for
connection. [Link]() method is used to connect to
particular database. Statement and ResultSet objects are used to execute query
and to store result of the query respectively.
Implementation:
package javaapplication;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class Connect {
public static void main(String[] args) {
// variables
Connection connection = null;
Statement statement = null;
ResultSetresultSet = null;
// Step 1: Loading or registering Oracle JDBC driver class
try {
[Link]("[Link]");
}
catch(ClassNotFoundExceptioncnfex)
{
[Link]("Problem in loading or " + "registering MS Access JDBC driver");
[Link]();
}
// Step 2: Opening database connection
try {
String msAccDB = "C:/users/admin/Documents/[Link]";
String dbURL = "jdbc:ucanaccess://" + msAccDB;
// Step 2.A: Create and get connection using DriverManager class
connection = [Link](dbURL);
// Step 2.B: Creating JDBC Statement
statement = [Link]();
// Step 2.C: Executing SQL & retrieve data into ResultSet
resultSet = [Link]("SELECT * FROM PLAYERS"); [Link]("ID\
tPlayerName\tAge\tRuns"); [Link]("==\t===========\t===\t=======");
// processing returned data and printing into console
while([Link]()) {
[Link]([Link](2) + "\t" +
[Link](3) + "\t" +
[Link](4) + "\t" +
[Link](5));
}}
catch(SQLExceptionsqlex){
[Link]();
}
finally
{
// Step 3: Closing database connection
try {
if(null != connection) {
// cleanup resources, once after processing
[Link]();
[Link]();
// and then finally close connection [Link]();
}
}
catch (SQLExceptionsqlex)
{
[Link]();
} }} }
Output/Conclusion: