Mca - Java Program Final
Mca - Java Program Final
Paper Code :
Batch : 2021-2023
Class & Semester : I MCA & 1ST Semester
SEMESTER I
Core Course - V - LAB – I JAVA PROGRAMMING LAB
1. Write a java application program to demonstrate class with constructors.
2. Write a java application program to demonstrate inheritance, interface and package.
3. Write a java application program to implement exception and Multi threading
concept.
4. Write a program to read, write and copy a file using byte streams or character
streams.
5. Develop a banking system using AWT and event handling.
6. Develop a programs using Swing to display the personal detail of an employee.
7. Implement TCP/IP and UDP protocol for message communication.
8. Using JDBC develop a student information system.
9. Implement client/server communication using servlets.
10. Develop a web page using JSP.
SEMESTER -I
AIM:
PROCEDURE:
STEP 2: Create a class EB bill that contains get data (), cell (),
of EB bill class.
STEP 4: Call the get data () using gets the input from the
{
int u;
if(units<=200)
{
r=units*1;
}
else
{
u=units-200;
r=100+u*2;
}
System.out.println("t\t\t ELECTRIC BILL");
System.out.println(“ “); System.out.println("\
tNAME :"+name); System.out.println("\tCODE :"+code);
System.out.println("\tUNITS CONSUMED :"+units);
System.out.println(" ");
System.out.println("\tTOTAL AMOUNT TO BE PAID
:"+r); return 0;
}
}
class show
{ public static void main(String args[])
{ int rs; electric_bill e=new electric_bill();
e.getdata();
rs=e.calculate();
}
}
OUTPUT:
C:\jdk1.7.0\bin>javac show.java
C:\jdk1.7.0\bin>java show
Enter the name
BHUVAN Enter the code
003
Enter the units 120
ELECTRIC BILL
NAME :BHUVANCODE :3
UNITS CONSUMED :120
C:\jdk1.7.0\bin>
RESULT:
AIM:
PROCEDURE:
STEP 3: Create a class EMP inside employee package emp class contain
Constructor,call(),display() method.
STEP 4: Create Empay class and import package create object for emp
class.
System.out.println("\n da : "+da);
System.out.println("\n pf: "+pf);
System.out.println("\n npay: "+npay);
}
}
OUTPUT:
C:\jdk1.7.0\bin>javac Emp.java
C:\jdk1.7.0\bin>javac Emppay.java
C:\jdk1.7.0\bin>java Emppay
EMPLOYEE DETAILS
Name : Rama
Employee ID
:IT101 Category :
Female bpay :
10000
hra : 500.0
da : 500.0
pf: 800.0
npay: 10200.0
RESULT:
Thus the above java program has been executed successfully.
3.Write a java application program to implement exception and Multi threading
concept.
AIM:
PROCEDURE:
class sample{
public static void main(String args[]){A
threadA=new A();
B threadB=new B();C
threadC=new C();
threadA.start();
threadB.start(); threadC.start();
}
}
OUTPUT:
RESULT:
AIM:
PROCEDURE:
STEP 2: Create a class are try block and catch block for the
class Division {
public static void main(String[] args) {
int a, b, result;
Scanner input = new Scanner(System.in);
System.out.println("Input two integers"); a
= input.nextInt();
b = input.nextInt();
try {
result = a / b;
System.out.println("Result = " + result);
}
catch (ArithmeticException e) {
System.out.println("Exception caught: Division by
zero.");
}
}
}
OUTPUT:
C:\jdk1.7.0\bin>javac Division.java
C:\jdk1.7.0\bin>java Division
0
Exception caught: Division by
zero. C:\jdk1.7.0\bin>
RESULT:
AIM:
To develop a java program to read and write with using byte system.
PROCEDURE:
STEP 2: Write a text to given text file using data output system(2,1) import
the java.
STEP 3: Read the text form the same file using data input stream.
STEP 4: Copy character by character from given file to new file using file input and
output stream.
import java.io.*;
public class DataInput_Stream{
public static void main(String args[])throws IOException{
DataOutputStream dataOut = new DataOutputStream(new
FileOutputStream("myfile.txt")); dataOut.writeUTF("hello hai welcome");
DataInputStream dataIn = new DataInputStream(new
FileInputStream("myfile.txt")); while(dataIn.available()>0){
String k =
dataIn.readUTF();
System.out.print(k+" ");
}
}
}
OUTPUT:
C:\jdk1.7.0\bin>javac DataInput_Stream.java
C:\jdk1.7.0\bin>java DataInput_Stream
hello hai
welcome C:\
jdk1.7.0\bin>
RESULT:
AIM:
PROCEDURE:
listener.
RESULT:
Thus the above java program has been executed successfully.
5(B).SWING EVENT HANDLER:
AIM:
PROCEDURE:
STEP 3: Insert table and one button raise the event handling
method.
RESULT:
AIM:
PROCEDURE:
STEP 3: Create a class EMP inside employee package emp class contain
Constructor,call(),display() method.
STEP 4: Create Empay class and import package create object for emp
class.
}
}
OUTPUT:
C:\jdk1.7.0\bin>javac Emp.java
C:\jdk1.7.0\bin>javac Emppay.java
C:\jdk1.7.0\bin>java Emppay
EMPLOYEE DETAILS
Name : Rama Employee
ID : IT101
Category : Female
bpay : 10000
hra : 500.0
da : 500.0
pf: 800.0
npay: 10200.0
RESULT:
Thus the above java program has been executed successfully.
7.Implement TCP/IP and UDP protocol for message communication.
AIM:
To develop a java program to create in simple TCP/IP and UDP protocol for
messagecommunication.
PROCEDURE:
STEP 3: Start the chat source and message for client wait units the client
information. STEP 4: Receive the message from server and given response
RESULT:
Thus the above java program has been executed successfully.
8.Using JDBC develop a student information system.
AIM:
PROCEDURE:
STEP 3: Get the import from user like name, no mark. STEP 4:
Calculate total argument and display text box. STEP 5: Store the
information to database.
Sql>desc tea;
TEA_NAME VARCHAR2(30),
SUPP_ID NUMBER(6),
PRICE NUMBER(6,2),
SALES NUMBER(6,2),
TOTAL NUMBER(6,2))
RESULT:
AIM:
PROCEDURE:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Wishing message</title>
</head>
<body>
<a href = "http://localhost:2020/WishSrvApp/test">Get wishing</a>
</body>
</html>
Web.xml
<web-app>
<servlet>
<servlet-name>abc</servlet-name>
<servlet-class>WishApp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>abc</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
</web-app>
Output:
When we click on the above link In the morning it displays following message.
RESULT:
AIM:
PROCEDURE:
Register_1.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Guru Registration Form</title>
</head>
<body>
<h1>Guru Register Form</h1>
<form action="guru_register" method="post">
<table style="with: 50%"><tr><td>First Name</td>
<td><input type="text" name="first_name"/></td>
</tr>
<tr><td>Last Name</td><td><input type="text" name="last_name" /></td>
</tr><tr>
<td>UserName</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td>Address</td>
<td><input type="text" name="address" /></td>
</tr>
<tr>
<td>Contact No</td>
<td><input type="text" name="contact" /></td>
</tr></table>
<input type="submit" value="Submit" /></form>
</body>
</html>
Guru_register.java
package demotest;
import java.io.IOException;
import javax.servlet.RequestDispatcher;import
javax.servlet.ServletException; import
javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import
javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class guru_register
*/
public class guru_register extends HttpServlet { private static final long
serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException {
// TODO Auto-generated method stubString
first_name =
request.getParameter("first_name");
String last_name = request.getParameter("last_name");
String username = request.getParameter("username");
String password = request.getParameter("password");
String address = request.getParameter("address");
String contact = request.getParameter("contact");
if(first_name.isEmpty() || last_name.isEmpty()
|| username.isEmpty() ||
password.isEmpty() ||
address.isEmpty() || contact.isEmpty())
{
RequestDispatcher req =
request.getRequestDispatcher("register_1.jsp");
req.include(request, response);
}
else
{
RequestDispatcher req =
request.getRequestDispatcher("register_2.jsp");
req.forward(request, response);
}
}
}
Register_2.jsp
RESULT: