Sie sind auf Seite 1von 82


BSNL Broadband connection: The components are, 1.BSNL DataOne 256kbps connection 2.HUAWETsmartAX MT880(modem) Configuring and Testing your Broadband connection: Step1: Setup the modem as per the instructions mentioned in the manual. Ensure that the RJII cable from the splitter is connected to the ADSL port and the RJ45 cable connects your machine to the Ethernet port of the modem. Step2: Change the IP properties of your Ethernet card to the following. Step3: Open the browser and type to go to the HUAWI configuration tool. Step4: Enter 'admin' as username and 'admin' as password. Step5: Expand the home node and select the WAN setting Step6: Under this webpage, configure the following: PVC number-pvco WAN Type-ppp Connection Type-pppoe VPI/VCI-0/35 DefaultRoute-Enabled Username-<your ISP username> Password-<your ISP password> useDNS-enabled MaxIdleTime-Always on Step7: Click Apply and allow the modem to restart. Step8: Close the browser window Step9: Open the browser and type Step10: Enter the 'admin' as username and 'admin' as password. Step11: You should see the summary page. The status is normally Red indicating that the connection is not ON.

Step12: Click on the plug icon in the note column to connect. Step13: After the connecting message, you should see the summary page again with the status turning green. Notice the IP address and Gateway address. Step14: Expand tools node and click on Misc. Step15: Type and click on ping. Step16: You should see Ping result: successful; Step17: Click on the LAN setting link under the advanced mode. Step18: Configure the following: IP address- Subnet Mask- Local Domain Name-Blank Step19: Click on apply and allow the modem to restart. Step20: Open the network properties of your Ethernet card and change the IP properties to the following; IPAddress- Subnet mask- Default gateway- Preferred DNS server- DNS server IP) Alternate DNS server- Step21: Open your browser and type your favourite URL. You should be on line by this time.

RESULT: Thus the study of internet connection procedure about BSNL broadband connection is done.


Aim : To write about the steps involved in sending and receiving mails from one or more clients. Algorithm : There are many servers available for sending and receving mails. Let us consider it as gmail. The steps are Step 1 : Open the web browser. Step 2 : In the address bar, type Step 3 : Login to the account by specifying an existing username and password. Step 4 : It leads to your gmail account page. Step 5 : To create the mail, click the 'Compose mail ' link. Step 6 : It leads to blank email message window. To To specify the recepients email address. Addcc To send the mails to more than one person. Subject To specify the main matter of the mail. We can also specify as a blank subject. Attach a file It is used to attach the files such as video, music, images etc................ Step 7 : Inside the editting area, type the text. We can also change the format of the text such as font, size, font style etc. Step 8 : After entering the message, click the send button . Step 9 : If the message is delivered, then it display the report as " Your message has been send " . Step 10 : You can also reply and forward the mail you have received. Step 11 : After completion of your process, signout the page.


RESULT: Thus the Sending and Receiving mails from one or more email clients is done.


Video Conferencing in Yahoo Messenger Click the Webcam button on the Instant Message or Voice Conference window Choose File | Preference in the My Webcam window to display the yahoo Messenger Preferences dialog box and click the Webcam category. Set the privacy settings to control who can see your image Click the Camera settings button to display the Video Source dialog box. Move the sliders to make your image brighter or darker and to make other adjustments. Click OK after completing. Click OK to dismiss the Yahoo Messenger Preferences dialog box. Video Conferencing in Windows Messenger In a conversation window, click the Start Camera to enable both voice and video. Windows Messenger sends a message to ask the other person whether they agree to use voice and video If the other person agrees, the image appears in the upper-right corner of the conversation window.

RESULT: Thus the Video Conferencing demonstration is done.


Aim: To download and installing software and setting up path and close path. Algorithm: Step 1 : Open a web browser like internet explorer. Step 2 : Open a google website by selecting appropriate websit from the address tag. Step 3 : Search as " free download Java " and click the search button. Step 4 : click " Download Free Java Software" link from the various link. This link is from the "http\\\getjava\index.jsp\". Step 5 : Then click the " Free java Download " button to download the exe file of the software. Step 6 : The downloading window display as follows ,

Step 7 : In the above window , click the save button to select the path top save the software file. After saving the file , the software file download starts. Step 8 : After download completes , the following window will display ,

Step 9 : Click the " Open folder " button to check whether the file being downloaded.

INSTALLING EXE FILE: Step 1 : Double click the icon of downloaded exe. You will see Java Setup window as shown below,

Step 2: Click the 'Install' button to install the java software. Step 3: Now 'Downloading Java Installer' window will be displayed. In that installer will be Downloaded with in a second. Step 4: Next the 'Java Setup-Progress' window will be displayed. In that we can check the Status of installing java. Step 5: After installing, the 'Java Setup-Complete' window will be displayed and click the Close button to close the window. Step 6: To make available Java Compiler and Runtime Environment for compiling and running java programs, we set the system environment variables. Step 7: Right click 'My Computer' and select the properties.In properties window, click Advanced -> Environment Variables. Now select the path in system variables and Click 'Edit' button. In next window, add 'c:/ProgramFiles/JavaSetup6u22' to Variable value and click OK -> OK -> OK.

Step 8 : Now set the JAVA_HOME variable and set its value to 'c:/ProgramFiles/JavaSetup6u22' If this variable has not been declared earlier then create a new system variable by clicking on 'New' button and give variable name as 'c:/ProgramFiles/JavaSetup6u22'. Now Click OK. This variable is used by other applications to find jdk installation directory. For eg, Tomcat Server needs 'JAVA_HOME' vaiable to find the installation directory Of jdk. Step 9 : Now check that you have installed jdk successfully and it is working fine. Just go to the Command Prompt and type javac and hit 'enter' key you will get the below, C:\javac Usage:javac<options><source files> Now you can create, compile and run java programs.

RESULT: Thus downloading and installing the java software is done successfully

FTP FTP is an acronym for File Transfer Protocol. It represents a widely-used, method for transferring files between two computers. One of the computers must be set up as a host or server. The other, known as the client, is the computer that you are using. There are two basic types of operations: When you retrieve a file from the server, you are performing a "get" operation. This is also known as "downloading." When you post a file to the server, your are performing a "put" operation. This is also known as "uploading." When you connect to an FTP server, you must send a username and password. In many cases the username "anonymous" may be used to mean "I am a visitor." Even if you are visiting an FTP site and are not prompted for a username, the FTP server will assign the anonymous username to you. Most FTP servers ask which username you would like to use. Types of FTP "Programs" There are a number of programs to help transfer files using FTP. In order to keep network sniffers from reading your password when you connect to our ftp server, we use a secure ftp server. This means that you must use a secure ftp client that uses "SFTP", or secure file transfer protocol. FileZilla is a great program to use and runs on Windows, Macs, and Linux environments. Download and install filezilla software. Using FileZilla to transfer files There are only a few steps to this process. 1. Start FileZilla. You'll see a list of your folders and files on the left side of the program window. 2. Make a connection with the file server. You can enter the server information in the "Quick connect bar" at the top of the screen. Host: s Username: your username Password: your password Port: 22 3. Now that you're logged in, you'll see a list of folders and files on the server. Double-click on a folder to open that folder and see what's inside. (This works for both lists--your computer on the left side, and the server on the right side.) Use this method to navigate both systems so you can see the file(s) you want to transfer on one side, and you can see the destination folder on the other side.

4. Now, just drag and drop the file(s) you want to transfer. There will be a status of the transfer at the bottom of the screen that shows the progress of your transfer. 5. All done! Just log out and continue on your merry way.


RESULT: Thus the FTP is done successfully.


Aim:Write a program to create a Web page using the HTML code. Procedure:Step 1: Start a HTML program having form, textboxes and command buttons. Step 2: Form named f1 having two text boxes, one for Username & another for password. Step 3: A command button is used to submit the form. Step 4: A link moves to saravana1.html while the form is submitted. Step 5: In saravana1.html, we have two links pictures.html & software.html downloadpictures & softwares. Step 6: Stop the HTML program.

LOGIN FORM <html> <head> <title>free downloads for mca students </title> </head> <body bgcolor="cyan"> <font color=red size=15><center>Free Downloads</center></font> <br> <br> <form name=f1 action="d:\html\saravana1.html"> <table border=0 cellspacing=0 width=500 align=center> <font size=5> <tr> <td align=left> <b>USER NAME:</b> </td> <td> <input type="text" name="user"> </td> </tr> <tr> <td align=left> <b>PASSWORD:</b> </td> <td> <input type="password" name="pass"> </td> </tr> </table> </font> <center> <br> <input type="submit" name="insert" value="submit"> </center> </form> <br><br> <a href="d:\html\signup.html"><marquee behavior=alternate><font size=6 color=green>click here to join our mem</font></marquee></a> <br> <br> <font color=blue><b><center><a href="d:\html\about.html">aboutus</a> <a href="e:\html\part.html"> partnersites</center></b></font> </body> </html>


RESULT: Thus the Web page design using HTML is done.

Aim: Write a program to implement Inheritance. Algorithm Step 1: Start the program Step 2: Declare the class Rollno with method getrollno() Step 3: Declare the class Department with method getdept() Step 4: Declare the class Name with method getnames() Step 5: Declare the class Address with method getaddr() Step 6: Declare the class Inheritance which contain the main method Step 7: Declare the object for the classes Name, Department and Address Step 8: For Single Inheritance call the method getrollno() using the object of Name Step 9: For Multiple Inheritance call the methods getname () and getaddr () using the object of Address class. Step 10: For Hierarchical Inheritance call methods getrollno () and getdept () using the object of Department class. Step 11: Stop the program.

Program import*; class Rollno { int n; void getrollno() throws IOException { DataInputStream j=new DataInputStream(; System.out.println("\nEnter the rollno:"); n=Integer.parseInt(j.readLine()); System.out.println("\nRollno : " +n); } } class Department extends Rollno { String dept; void getdept() throws IOException { DataInputStream d=new DataInputStream(; System.out.println("\nEnter the department:"); dept=d.readLine(); System.out.println("\nDepartment : " +dept); } } class Name extends Rollno { String name; void getname() throws IOException { DataInputStream h=new DataInputStream(; System.out.println("\nEnter the name :"); name=h.readLine(); System.out.println("\nName : " +name); } } class Address extends Name { String place; void getaddr() throws IOException { System.out.println("\nEnter the place: "); DataInputStream d=new DataInputStream(; place=d.readLine(); System.out.println("\nPlace : " +place); } }

class Inheritance { public static void main(String args[]) throws IOException { Name ob1=new Name(); Department ob2=new Department(); Address ob3=new Address(); System.out.println("\tSingle Inheritance"); ob1.getrollno(); System.out.println("\tMultilevel Inheritance"); ob3.getname(); ob3.getaddr(); System.out.println("\tHierarchical Inheritance"); ob2.getrollno(); ob2.getdept(); } }

OUTPUT Single Inheritance Enter the rollno: 11 Rollno : 11 Multilevel Inheritance Enter the name : Ram Name : Ram

Enter the place: Trivandrum Place : Trivandrum Hierarchical Inheritance Enter the rollno: 1 Rollno :1

Enter the department: MCA Department : MCA Press any key to continue...

RESULT: The program Inheritance is executed successfully and output is verified.

Aim: Write a java program using 'this' keyword. Algorithm Step 1: Start the program Step 2: Declare a class Sum with methods as sum(),division(),difference(),product() Step 3: Declare the main class as This Step 4: Declare two variables x and y of type int. Step 5: Read x and y Step 6: Create objects for methods in class This1 and perform Addition, Subtraction, Multiplication and Division Step 7: Stop the program.

Program import*; class Sum { int one; int two; Sum(int one,int two) {; this.two=two; } int sum() { return(one+two); } int difference() { return(one-two); } int product() { return(one*two); } int division() { return(one/two); } } class This { public static void main(String args[])throws IOException { int x,y; BufferedReader obj=new BufferedReader(new InputStreamReader(; System.out.println("Enter two values"); x=Integer.parseInt(obj.readLine()); y=Integer.parseInt(obj.readLine()); Sum MySum1=new Sum(x,y); Sum MySum2=new Sum(x,y); Sum MySum3=new Sum(x,y); Sum MySum4=new Sum(x,y); int sum; int dif; int pro; int val;

sum=MySum1.sum(); dif=MySum1.difference(); pro=MySum1.product(); val=MySum1.division(); System.out.println("Sum = "+sum); System.out.println("Difference = "+dif); System.out.println("Product = "+pro); System.out.println("Division = "+val); } }

OUTPUT Enter two values 10 5 Sum = 15 Difference = 5 Product = 50 Division = 2 Press any key to continue...

RESULT: The program using 'this' keyword is executed successfully and output is verified.

Aim: Write a program to perform Polymorphism. Algorithm Step 1: Start the program Step 2: Create a class and initialize variables and define methods in it Step 3: The method area() is overloaded to find the area of a square, rectangle and circle Step 4: Read the option number 1,'Square' Read the value for 'a'. Call area (). Step 5: Read the option 2, 'Rectangle' Read the length and breadth Call area() Step 6: Read the option 3, 'Circle' Read the radius Call area() Step 7: Display the area of Square, Rectangle and Circle. Step 8: Stop the program.

Program import*; import java.lang.*; class Area { double pi=3.14; double a; void area(int x) { a=x*x; System.out.println("Area of Square is:"+a); } void area(int l,int b) { a=l*b; System.out.println("Area of Rectangle is:"+a); } void area(float r) { a=pi*r*r; System.out.println("Area of Circle is:"+a); } } class Poly { public static void main(String args[]) throws IOException { DataInputStream in=new DataInputStream(; Area a=new Area(); int n,x,l,b; float r; do { System.out.println("\n Menu"); System.out.println("\n1.Square\n2.Rectangle\n3.Circle\n"); System.out.println("\nEnter your option:"); n=Integer.parseInt(in.readLine()); switch(n) { case 1: System.out.println("\nSQUARE"); System.out.println("\nEnter the area:"); x=Integer.parseInt(in.readLine()); a.area(x); break; case 2: System.out.println("\nRECTANGLE"); System.out.println("\nEnter the length and breadth:");

l=Integer.parseInt(in.readLine()); b=Integer.parseInt(in.readLine()); a.area(l,b); break; case 3: System.out.println("\nCIRCLE"); System.out.println("\nEnter the radius:"); r=Float.parseFloat(in.readLine()); a.area(r); break; default: System.out.println("Exiting"); break; } } while(n!=4); } }

OUTPUT Menu 1.Square 2.Rectangle 3.Circle Enter your option: 1 SQUARE Enter the area: 10 Area of Square is: 100.0 Menu 1.Square 2.Rectangle 3.Circle Enter your option: 2 RECTANGLE Enter the length and breadth: 10 5 Area of Rectangle is: 50.0 Menu 1.Square 2.Rectangle 3.Circle Enter your option: 3 CIRCLE Enter the radius: 5 Area of Circle is: 78.5

RESULT: The program for Polymorphism is executed successfully and output is verified.

Aim: Write a program to implement Package Algorithm Step 1: Start the program Step 2: Create a package named Employee with class Emp and save this file in a folder name Employee i.e., with the same name s that of package. Step 3: Create a class Emppay and import the package Employee to this file. Step 4: Create an object for the Emp class in the Emppay class. Step 5: Call the functions of Emp with the object Step 6: Stop the program.

Program //Creation of Package// package Employee; public class Emp { public String name,category; public int emp_id; public double basicpay,ta,da,pf,netpay; public Emp(String n,String c,int id,double bp) { name=n;category=c;emp_id=id;basicpay=bp; } public void netpaycalc() { ta=4500.00; pf=(.25*basicpay); da=(.60*basicpay); netpay=basicpay+ta+da+pf; } public void display() { System.out.println("Employee details"); System.out.println("Name "+name); System.out.println("Category "+category); System.out.println("Employee id "+emp_id); System.out.println("Basic pay "+basicpay); System.out.println("Net salary "+netpay); } } //Package implementation// import Employee.*; import*; class Emppay { public static void main(String args[])throws IOException { DataInputStream in=new DataInputStream(; String en,ec,s; int eid; double bpy; System.out.println("Enter Employee Name:- "); en=in.readLine(); System.out.println("Enter the category:- "); ec=in.readLine(); System.out.println("Enter employee id:- ");

eid=Integer.parseInt(in.readLine()); System.out.println("Basic pay:- "); s=in.readLine(); bpy=Double.parseDouble(s); Emp e=new Emp(en,ec,eid,bpy); e.netpaycalc(); e.display(); }}

OUTPUT Enter Employee Name:Rajesh Enter the category:sw engg Enter employee id:007 Basic pay:18000 Employee details Name Rajesh Category sw engg Employee id 7 Basic pay 18000.0 Net salary 37800.0 Press any key to continue...

RESULT: The program Package is executed successfully and output is verified.

Aim: Write a program to perform user defined Exception Handling. Algorithm Step 1: Start the program Step 2: Declare the class Exception Demo with methods errfunction which throws Arithmetic Exception Step 3: Catch the user defined null pointer Exception Step 4: Inside finally block user defined exception is specified. Step 5: If errors found display the message "finally will always executed after try". Step 6: Stop the program.

Program import*; public class ExceptionDemo { static void errFunction() throws ArithmeticException { int a=22; try { throw new NullPointerException("User Defined Name"); } catch(NullPointerException npe) { System.out.println("Caught"+npe); } a/=0; } public static void main(String args[]) { try { errFunction(); } catch (ArithmeticException ae) { System.out.println("Caught"+ae); } finally { System.out.println("Finally will always execute after try"); } }}

OUTPUT Caughtjava.lang.NullPointerException: User Defined Name Caughtjava.lang.ArithmeticException: / by zero Finally will always execute after try Press any key to continue...

RESULT: The program Exception Handling is executed successfully and output is verified.

import javax.swing.*; import javax.swing.JOptionPane; import java.awt.*; import java.awt.event.*; /*<applet code=Calculator height=300 width=200></applet>*/ public class Calculator extends JApplet { public void init() { CalculatorPanel calc=new CalculatorPanel(); getContentPane().add(calc); } } class CalculatorPanel extends JPanel implements ActionListener { JButton n1,n2,n3,n4,n5,n6,n7,n8,n9,n0,plus,minus,mul,div,dot,equal; static JTextField result=new JTextField("0",45); static String lastCommand=null; JOptionPane p=new JOptionPane(); double preRes=0,secVal=0,res; private static void assign(String no) { if((result.getText()).equals("0")) result.setText(no); else if(lastCommand=="=") { result.setText(no); lastCommand=null; } else result.setText(result.getText()+no); } public CalculatorPanel() { setLayout(new BorderLayout()); result.setEditable(false); result.setSize(300,200); add(result,BorderLayout.NORTH); JPanel panel=new JPanel(); panel.setLayout(new GridLayout(4,4));

n7=new JButton("7"); panel.add(n7); n7.addActionListener(this); n8=new JButton("8"); panel.add(n8); n8.addActionListener(this); n9=new JButton("9"); panel.add(n9); n9.addActionListener(this); div=new JButton("/"); panel.add(div); div.addActionListener(this); n4=new JButton("4"); panel.add(n4); n4.addActionListener(this); n5=new JButton("5"); panel.add(n5); n5.addActionListener(this); n6=new JButton("6"); panel.add(n6); n6.addActionListener(this); mul=new JButton("*"); panel.add(mul); mul.addActionListener(this); n1=new JButton("1"); panel.add(n1); n1.addActionListener(this); n2=new JButton("2"); panel.add(n2); n2.addActionListener(this); n3=new JButton("3"); panel.add(n3); n3.addActionListener(this); minus=new JButton("-"); panel.add(minus); minus.addActionListener(this); dot=new JButton("."); panel.add(dot); dot.addActionListener(this); n0=new JButton("0"); panel.add(n0); n0.addActionListener(this); equal=new JButton("=");

panel.add(equal); equal.addActionListener(this); plus=new JButton("+"); panel.add(plus); plus.addActionListener(this); add(panel,BorderLayout.CENTER); } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==n1) assign("1"); else if(ae.getSource()==n2) assign("2"); else if(ae.getSource()==n3) assign("3"); else if(ae.getSource()==n4) assign("4"); else if(ae.getSource()==n5) assign("5"); else if(ae.getSource()==n6) assign("6"); else if(ae.getSource()==n7) assign("7"); else if(ae.getSource()==n8) assign("8"); else if(ae.getSource()==n9) assign("9"); else if(ae.getSource()==n0) assign("0"); else if(ae.getSource()==dot) { if(((result.getText()).indexOf("."))==-1) result.setText(result.getText()+"."); } else if(ae.getSource()==minus) { preRes=Double.parseDouble(result.getText()); lastCommand="-"; result.setText("0"); } else if(ae.getSource()==div) { preRes=Double.parseDouble(result.getText()); lastCommand="/"; result.setText("0"); } else if(ae.getSource()==equal) { secVal=Double.parseDouble(result.getText()); if(lastCommand.equals("/")) res=preRes/secVal; else if(lastCommand.equals("*")) res=preRes*secVal; else if(lastCommand.equals("-")) res=preRes-secVal; else if(lastCommand.equals("+")) res=preRes+secVal;

result.setText(" "+res); lastCommand="="; } else if(ae.getSource()==mul) { preRes=Double.parseDouble(result.getText()); lastCommand="*"; result.setText("0"); } else if(ae.getSource()==plus) { preRes=Double.parseDouble(result.getText()); lastCommand="+"; result.setText("0"); } } }


RESULT: The program for Calculator Application is executed successfully and output is verified.

Aim:Write a program to create Fahrenheit to Centigrade Converter. Procedure:Step 1: Start the Program. Step 2: Declare a class Ftoc which extends Frame and implements Action Listener Step 3: Define a constructor ftoc () Add textfield, label, and button into the frame Step 4: perform the fahrenheat calculation by inputting Fahrenheat value to the text field and click the button convert to centigrade. Step 5: Calculate using TC= (5/9.0)*(Double.parseDouble (tf.getText ())-32) Step 6: Display the result Step 7: stop the Program.

Program import java.awt.*; import java.awt.event.*; import*; public class ftoc extends Frame implements ActionListener { Button b; TextField tf; Label lbl1,lbl2; ftoc() { super("Faherheit to Centigrade Converter"); Panel p=new Panel(); p.setLayout(new GridLayout(1,2)); lbl1=new Label("Type Farenheit value",Label.RIGHT); tf=new TextField(20); p.add(lbl1); p.add(tf); b=new Button("Convert to Centigrade"); b.addActionListener(this); lbl2=new Label("",Label.CENTER); add(p,BorderLayout.NORTH); add(b,BorderLayout.CENTER); add(lbl2,BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); } public void actionPerformed(ActionEvent ae) { try { double Tc=(5/9.0)*(Double.parseDouble(tf.getText())-32); lbl2.setText("Equivalent Centigrade:"+Double.toString(Tc)); } catch(Exception e) { lbl2.setText("in Valid Fahrenheit value,give valid number"); } } public static void main(String args[]) { ftoc fcv=new ftoc();

fcv.setLocation(400,400); fcv.setVisible(true); fcv.setSize(200,200); fcv.pack(); }}

OUTPUT: D:\FRAME>javac D:\FRAME>java ftoc

RESULT: The program for Fahrenheit to Centigrade conversion is executed successfully and output is verified.


AIM:Write a program for multithreading and deadlock avoidance. PROCEDURE:Step 1: Start the Program Step 2: declare the class Syncstack with pop () and push () Step 3: declare the function call () Step 4: Declare the class Consumer implements RunnableInterface define the constructor Consumer(Syncstack s) define the function runs() Consumer threads sleeps as thread.sleep(int)(Math. random()*100) display the Consumer Number stops while any interruption Step 5: Runnable interface implements another class Producer is Declared define the constructor Producer(Syncstack s) define the function run() Producer threads sleeps as thread.sleep(int)(Math. random()*100) display the Producer Number stops while any interruption occur Step 6: In the main class SyncTest, create objects for classes SyncStack, Producer, Consumer thread Step 7: call PT1, start () and CT1, start () Step 8: Stop the Program.

Program import java.util.*; class SyncStack { private List buffer=new ArrayList(100); public synchronized char pop() { char c; while(buffer.size()==0) { try { this.wait(); } catch(InterruptedException e) { } } c=((Character)buffer.remove(buffer.size()-1)).charValue(); return c; } public synchronized void push(char c) { this.notify(); //wakeup the Thread Character charObj=new Character(c); buffer.add(charObj); } } class Consumer implements Runnable { private SyncStack theStack; private int num; private static int counter=1; public Consumer(SyncStack s) { theStack=s; num=counter++; } public void run() { char c; for(int i=0;i<5;i++) { c=theStack.pop(); System.out.println("\nConsumer "+num+": "+c); try {

Thread.sleep((int)(Math.random()*1000)); } catch(InterruptedException e) { } } System.out.println("\nConsumer "+num+" Stops"); } } class Producer implements Runnable { private SyncStack theStack; private int num; private static int counter=1; public Producer(SyncStack s) { theStack=s; num=counter++; } public void run() { char c; for(int i=0;i<5;i++) { c=(char)(Math.random()*26+'A'); theStack.push(c); System.out.println("\nProducer "+num+": "+c); try { Thread.sleep((int)(Math.random()*1000)); } catch(InterruptedException e) { } } System.out.println("\nProducer "+num+" Stops"); } } class SyncTest { public static void main(String arg[]) { SyncStack stack=new SyncStack(); Producer p1=new Producer(stack); Thread PT1=new Thread(p1); System.out.println("Producer-1 Thread Starts"); PT1.start();

Consumer c1=new Consumer(stack); Thread CT1=new Thread(c1); System.out.println("Consumer-1 Thread Starts"); CT1.start(); } }

OUTPUT Producer-1 Thread Starts Consumer-1 Thread Starts Producer 1: B Consumer 1: B Producer 1: G Producer 1: O Producer 1: N Producer 1: O Producer 1 Stops Consumer 1: O Consumer 1: N Consumer 1: O Consumer 1: G Consumer 1 Stops Press any key to continue...

RESULT: The program for Application of threads-Deadlock Avoidance is executed successfully and output is verified.

Aim:Write a program to demonstrate file operations Procedure:Step 1: Start the Program. Step 2: Create three files with class names Newfile, Copyfile, and Show file Step 3: In the first file ,create a new file to read and write Step 4: In the 2nd one, copy a text file to another Step 5: In the 3rd one ,display the copied text file Step 6: Stop the Program.

Creating a new file import*; class newfile { public static void main(String arg[]) throws IOException { int i; DataInputStream in=new DataInputStream(; FileWriter fout; try { fout=new FileWriter(arg[0]); } catch(FileNotFoundException e) { System.out.println("Error : Opening New File"); return; } do {; if(i!='@') fout.write((char)i); }while(i!='@'); fout.close(); } } Copying a file to another import*; class copyfile { public static void main(String arg[]) throws IOException { int i; FileInputStream fin; FileOutputStream fout; try { fin=new FileInputStream(arg[0]); fout=new FileOutputStream(arg[1]); } catch(FileNotFoundException e) { System.out.println("Error : Opening Files"); return; }

try { do {; if(i!=-1) fout.write(i); }while(i!=-1); } catch(IOException e) { System.out.println("Error"); return; } fin.close(); fout.close(); } } Displaying the file import*; class showfile { public static void main(String arg[]) throws IOException { int i; FileInputStream fin; try { fin=new FileInputStream(arg[0]); } catch(FileNotFoundException e) { System.out.println("Error : Opening File"); return; } do {; if(i!=-1) System.out.print((char)i); }while(i!=-1); fin.close(); } }

OUTPUT: C:\MCA>java newfile text1.txt Welcome to MCA Department@ C:\MCA>java showfile text1.txt Welcome to MCA Department C:\MCA>java copyfile text1.txt text2.txt C:\MCA>java showfile text2.txt Welcome to MCA Department

RESULT: The program for Reading and Writing text files are executed successfully and output is verified.


Aim:Write a program demonstrate image file and manipulation Procedure:Step 1: Start the program. Step 2: Create class ConvolveApp extends JFrame Set layout and borderAdd buttons for blurring, sharpening, reseting & editing. Step 3: Create class ButtonListener implements ActionListener. Perform actions for Sharpen button, Blurring button, Edit button, & Reset buttons, if equals. Step 4: Create class CPanel extends JLabel Set background color to black & load image. Define void update(Graphics g), void paintComponent (Graphics g) Step 5: Stop the program

Program import java.awt.*; import java.awt.image; import java.awt.event.*; import javax.swing.border.TitledBorder; public class ConvolveApp extends JFrame { CPanel displayPanel; JButton sharpenButton, blurringButton, edButton, resetButton; public ConvolveApp() { super(); Container container = getContentPane(); displayPanel = new CPanel(); container.add(displayPanel); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 2)); panel.setBorder(new TitledBorder( "Click a Button to Perform the Associated Operation and Reset...")); sharpenButton = new JButton("Sharpen"); sharpenButton.addActionListener(new ButtonListener()); blurringButton = new JButton("Blur"); blurringButton.addActionListener(new ButtonListener()); edButton = new JButton("Edge Detect"); edButton.addActionListener(new ButtonListener()); resetButton = new JButton("Reset"); resetButton.addActionListener(new ButtonListener()); panel.add(sharpenButton); panel.add(blurringButton); panel.add(edButton); panel.add(resetButton); container.add(BorderLayout.SOUTH, panel); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setSize(displayPanel.getWidth(), displayPanel.getHeight() + 10); setVisible(true); } public static void main(String arg[]) { new ConvolveApp(); } class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) {

JButton button = (JButton) e.getSource(); if (button.equals(sharpenButton)) { displayPanel.sharpen(); displayPanel.repaint(); } else if (button.equals(blurringButton)) { displayPanel.blur(); displayPanel.repaint(); } else if (button.equals(edButton)) { displayPanel.edgeDetect(); displayPanel.repaint(); } else if (button.equals(resetButton)) { displayPanel.reset(); displayPanel.repaint(); } } } } class CPanel extends JLabel { Image displayImage; BufferedImage biSrc; BufferedImage biDest; // Destination image is mandetory. BufferedImage bi; // Only an additional reference. Graphics2D big; CPanel() { setBackground(; loadImage(); setSize(displayImage.getWidth(this), displayImage.getWidth(this)); createBufferedImages(); bi = biSrc; } public void loadImage() { displayImage = Toolkit.getDefaultToolkit().getImage("largeJava2sLogo.jpg"); MediaTracker mt = new MediaTracker(this); mt.addImage(displayImage, 1); try { mt.waitForAll(); } catch (Exception e) { System.out.println("Exception while loading."); } if (displayImage.getWidth(this) == -1) { System.out.println("No jpg file"); System.exit(0); } } public void createBufferedImages() { biSrc = new BufferedImage(displayImage.getWidth(this), displayImage.getHeight(this), BufferedImage.TYPE_INT_RGB);

big = biSrc.createGraphics(); big.drawImage(displayImage, 0, 0, this); biDest = new BufferedImage(displayImage.getWidth(this), displayImage.getHeight(this), BufferedImage.TYPE_INT_RGB); } public void sharpen() { float data[] = { -1.0f, -1.0f, -1.0f, -1.0f, 9.0f, -1.0f, -1.0f, -1.0f,-1.0f }; Kernel kernel = new Kernel(3, 3, data); ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP,null); convolve.filter(biSrc, biDest); bi = biDest; } public void blur() { float data[] = { 0.0625f, 0.125f, 0.0625f, 0.125f, 0.25f, 0.125f, 0.0625f, 0.125f, 0.0625f }; Kernel kernel = new Kernel(3, 3, data); ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); convolve.filter(biSrc, biDest); bi = biDest; } public void edgeDetect() { float data[] = { 1.0f, 0.0f, -1.0f, 1.0f, 0.0f, -1.0f, 1.0f, 0.0f,-1.0f }; Kernel kernel = new Kernel(3, 3, data); ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); convolve.filter(biSrc, biDest); bi = biDest; } public void reset() { big.setColor(; big.clearRect(0, 0, bi.getWidth(this), bi.getHeight(this)); big.drawImage(displayImage, 0, 0, this); bi = biSrc; } public void update(Graphics g) { g.clearRect(0, 0, getWidth(), getHeight()); paintComponent(g); } public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2D = (Graphics2D) g; g2D.drawImage(bi, 0, 0, this); } }

OUTPUT D:\IMAGE>javac D:\IMAGE>java ConvolveApp

RESULT: The program for Reading image files and Manipulating is executed successfully and output is verified.


Aim: Write a program for Remote method invocation. Algorithm Step 1: Start the program Step 2: Create an interface AddserverIntf Declare the method add() in it Complie Step 3: Declare a class AddserverImpl that extends UnicastRemote object, which implements AddserverIntf. Define the method AddserverImpl() and add() to add two numbers. Compile Step 4: Declare a class Addclient that gives input a & b Compile Step 5: Declare the class Addserver which responds to the input from the client. Compile Step 6: Run rmic AddserverImpl Step 7: Start RMI registry Step 8: Run the client & strategy. Step 9: Display the result Step 10: Stop the program

Program /* INTERFACE */ import java.rmi.*; public interface AddServerIntf extends Remote { double add(double d1,double d2)throws RemoteException; }

/* CLIENT */ import java.rmi.*; public class AddClient { public static void main(String arg[]) { try { String addServerURL="rmi://"+arg[0]+"/AddServer"; AddServerIntf addServerInf=(AddServerIntf)Naming.lookup(addServerURL); System.out.println("First number is :arg[1]"); double d1=Double.valueOf(arg[1]).doubleValue(); System.out.println("Second no: is :arg[2]"); double d2=Double.valueOf(arg[2]).doubleValue(); System.out.println("The sum is:"+addServerInf.add(d1,d2)); } catch(Exception e) { System.out.println("Exception "+e); } } }

/* SERVER IMPLEMENTATION */ import java.rmi.*; import java.rmi.server.*; public class AddServerImpl extends UnicastRemoteObject implements AddServerIntf { public AddServerImpl()throws RemoteException {} public double add(double d1,double d2)throws RemoteException

{ return d1+d2; } }

/* SERVER */ import*; import java.rmi.*; public class AddServer { public static void main(String arg[]) { try { AddServerImpl addServerImpl=new AddServerImpl(); Naming.rebind("AddServer",addServerImpl); } catch(Exception e) { System.out.println("Exception"+e); } } }

OUTPUT D:\rmi>javac D:\rmi>javac D:\rmi>javac D:\rmi>javac D:\rmi>rmic AddServerImpl D:\rmi>start rmiregistry

D:\rmi>java AddServer D:\rmi>java AddClient joseph 8 9 First number is :9 Second no: is :8 The sum is:17.0

RESULT: The program RMI application to access a remote method is executed successfully and output is verified.

Aim: Write a program to demonstrate Servlet Algorithm Step 1: Start Step 2: Create a HTML program Step 3: Create a form named form1 with get method and perform actions Step 4: Input name, id, phone no., basic, da, hra, pf using text box Step 5: Create text area for address. Step 6: Submit the form using submit button & reset it using reset button Step 7: Create a javafile named Step 8: import servlet, util, io, packages. Step 9: Declare class test extends HttpServlet Get the parameters name, id, sex, design., address, phone no. from the HTML file. Calculate netsal=basic+hra+da-pf Display name, id, sex, design., phone, address, basicpay, da, hra,pf & netsalary. Step 10: Stop

Program TEST.JAVA import*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class test extends HttpServlet { public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { String name=request.getParameter("name"); String id=request.getParameter("id"); String sex=request.getParameter("sex"); String desig=request.getParameter("desig"); String add=request.getParameter("add"); String phone=request.getParameter("phone"); int basic=Integer.parseInt(request.getParameter("basic")); int da=Integer.parseInt(request.getParameter("da")); int hra=Integer.parseInt(request.getParameter("hra")); int pf=Integer.parseInt(request.getParameter("pf")); int netsal=basic+hra+da-pf; response.setContentType("text/html"); PrintWriter pw=response.getWriter(); pw.println("<b> Name : "+name+"<br>"); pw.println("<b> ID : "+id+"<br>"); pw.println("<b> Sex : "+sex+"<br>"); pw.println("<b> Designation : "+desig+"<br>"); pw.println("<b> Add : "+add+"<br>"); pw.println("<b> Phone : "+phone+"<br>"); pw.println("<b> Basic Pay : "+basic+"<br>"); pw.println("<b> DA : "+da+"<br>"); pw.println("<b> HRA : "+hra+"<br>"); pw.println("<b> PF : "+pf+"<br>"); pw.println("<b> Net Salary : "+netsal+"<br>"); } }

TEST.HTML <html> <form name="form1" method="get" action="http://localhost:8080/servlet/test"> <center><h1>Employee Payment Details Processing Form</h1></center> <br> <br> Name <input type=text name="name" value=""><br> ID <input type=text name="id" value=""><br> Sex <input type="radio" value="Male" name=sex>Male <input type="radio" value="Female" name=sex>Female <br> <select name="desig" size=1> Designation <option value="Manager">Manager</option> <option value="Asst.Manager">Asst.Manager</option> <option value="Typist">Typist</option> <option value="Clerk">Clerk</option> </select><br> Address for Communication <br> <textarea name="add" rows=5 cols=15> </textarea><br> Phone Number <input type=text name="phone" value=""><br> <h4> Salary Details </h4> Basic Pay <input type=text name="basic" value=""></br> DA <input type=text name="da" value=""><br> HRA <input type=text name="hra" value=""><br> PF <input type=text name="pf" value=""><br> <br> <input type=submit value="Submit"> <input type=reset value="Resat"> </form> </html>


RESULT: The program for Servlet is executed successfully and output is verified.