S.
no Name of Experiment Page no Date Sign
1 Wap in java to implement multiple inheritance using
interface.
2 A) Wap in java to show concept of Exception Handling.
B) Wap in java to show URL Processing.
3 Wap in java to show the concept of Socket
programming.
4 Wap to execute AWT.
5 Wap to implement JTree.
6 Wap to Implement ListBox.
7 Wap to show the concept of MutiThreading.
8 Wap to show the concept of I/O Stream.
9 Wap to Implement JTable.
10 Wap to create JDBC Connection
Wap in java to implement multiple inheritance using interface.
2. A) Wap in java to show concept of Exception Handling.
import java.util.*;
public class Main
{
public static void main(String[] args) {
int a,b,c;
System.out.println("Enter the value of a");
Scanner s1=new Scanner(System.in);
a=s1.nextInt();
System.out.println("Enter the value of b");
b=s1.nextInt();
try{
c=a/b;
System.out.println("The Value of c = " + c);
}catch(Exception e){
System.out.println("there is an Exception in Program");
}
finally
{
System.out.println("Finally block Executed");
}
}
}
2. B) Wap in java to show URL Processing.
import java.io.*;
import java.net.*;
public class Main
public static void main(String[] args) {
try {
URL a = new URL("https://saitmgurgaon.com/courses-offered/bachelor-of-technology-
cse/language=en#j2se");
System.out.println("port is=" + a.getPort());
System.out.println("path is=" + a.getPath());
System.out.println("host is=" + a.getHost());
System.out.println("Query is=" + a.getQuery());
System.out.println("DefaultPort is=" + a.getDefaultPort());
System.out.println("Authority is=" + a.getAuthority());
System.out.println("Protocol is=" + a.getProtocol());
System.out.println("File is=" + a.getFile());
System.out.println("Refrence is=" + a.getRef());
} catch(Exception e)
System.out.println(e);
Output:-
Wap in java to show the concept of Socket programming.
Server Side
import java.net.ServerSocket;
import java.net.Socket;
import java.io.InputStream;
import java.io.DataInputStream;
public class Server
{
public static void main(String args[]) throws Exception
{
ServerSocket sersock = new ServerSocket(5000);
System.out.println("server is ready");//message to know the server is
running
Socket sock = sersock.accept();
InputStream istream = sock.getInputStream();
DataInputStream dstream = new DataInputStream(istream);
String message2 = dstream.readLine();
System.out.println(message2);
dstream .close();
istream.close();
sock.close();
sersock.close();
}
}
Client Side
import java.net.Socket;
import java.io.OutputStream;
import java.io.DataOutputStream;
public class Client
{
public static void main(String args[]) throws Exception
{
Socket sock = new Socket("127.0.0.1", 5000);
String message1 = "Accept Best Wishes";
OutputStream ostream = sock.getOutputStream();
DataOutputStream dos = new DataOutputStream(ostream);
dos.writeBytes(message1);
dos.close();
ostream.close();
sock.close();
}
}
6 Wap to Implement ListBox.
import javax.swing.*;
import java.awt.*;
class ListBoxExample extends JFrame
ListBoxExample()
setLayout(new FlowLayout());
String[] language = {"Cobol","Fortran","Pascal","C","C++","Java","C#"};
JLabel lblLanguage = new JLabel("Choose the Language");
JList LstMonth = new JList(language);
JButton button=new JButton("Submit");
add(lblLanguage); add(LstMonth); add(button);
class ListBoxJavaExample
public static void main(String args[])
ListBoxExample frame = new ListBoxExample();
frame.setTitle("ListBox Java Example");
frame.setBounds(400,500,350,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
9 Wap to implement JTable.
import javax.swing.*;
import java.awt.*;
public class TreeMain {
public static void main(String[] args) {
final JFrame frame = new JFrame("JTable Demo");
String[] columns = {"Code", "Name", "High", "Low",
"Close", "Volume", "Change","Change %"};
Object[][] data = {
{"MBF", "CITYGROUP", 10.16, 10.16, 10.16, 200, 0.08,0.79},
{"MBL", "BANK OF AMERICA", 12.66, 12.66, 12.66, 6600, 0.13,1.04},
{"MJP", "Morgan Stanley Dean Witter & Co.", 24.97, 24.97, 24.97, 1000, -0.04,-0.16}
};
JTable table = new JTable(data, columns);
JScrollPane scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);
JLabel lblHeading = new JLabel("Stock Quotes");
lblHeading.setFont(new Font("Arial",Font.TRUETYPE_FONT,24));
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(lblHeading,BorderLayout.PAGE_START);
frame.getContentPane().add(scrollPane,BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(550, 200);
frame.setVisible(true);