Untitled
Untitled
Untitled
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
Button b1,b2,b3;
b1=new Button("Red");
b2=new Button("Green");
b3=new Button("Blue");
add(b1);
add(b2);
add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
String str=ae.getActionCommand();
if (str.equals("Red"))
setBackground(Color.red);
else if (str.equals("Green"))
setBackground(Color.green);
}
else if (str.equals("Blue"))
setBackground(Color.blue);
repaint();
g.drawString(msg,0,100);
/*
</APPLET>
*/
addMouseListener(new MyMouseAdapter());
showStatus("Mouse Pressed")
import java.net.*;
InetAddress ip [] = InetAddress.getAllByName("www.google.com");
for(int i=0;i<ip.length;i++)
System.out.println(ip[i].getHostAddress());
import java.net.*;
{
String host=”localhost”;
for(int i=0;i<1024;i++)
try{
catch(UnknownHostexception ex)
Break;
catch(IOException e){}
}
Consider the following program.
What should be the correction done in the program to get correct output?
import java.sql.*;
class Ddemo1
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection();
Statement s=c.createStatement();
while(rs.next())
s.close();
c.close();
import java.io.*;
import java.sql.*;
class updatdb
{try
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:stud");
Statement s = con.createStatement();
while(rs.next())
con.close();
catch(Exception e){ }
}
Consider the following program and identify the missing statement.
public class SimpleDemo
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
try
{ String jdbcurl="jdbc:mysql://localhost:3306/test";
System.out.println("Connection established");
stmt=con.createStatement();
while(rs.next())
System.out.print(rs.getInt(1)+"t");
System.out.print(rs.getString(2)+"t");
System.out.print(rs.getString(3)+"t");
System.out.print(rs.getFloat(4));
System.out.println();
catch(ClassNotFoundException e) { e.printStackTrace();}
catch(SQLException e) {e.printStackTrace()}
finally
{try {
rs.close();
stmt.close();
con.close();
catch(Exception e){}
}} }
Consider following code.Fill _____________statement in following code from option given below
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
response.setContentType("text/html");
Cookie c = cookies[i];
String name = c.getName();
response.addCookie(c);
}
following servlet read parameters passed through the html page. Write the correct HTML code for given
servlet. Import jba. Io.*;
import java.util.&;
import javax.servlet.*;
public viod serice request reg, ServletResponse res) throws ServletException, IOException {
PrintWriter pw = res.getWriter();
In following Java program fill statement showing *** . Select any one option from given options
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
HttpSession hs = *****************
response.setContentType(“text/html”);
PrintWriter pw=response.getWriter();
pw.print(“<B>”);
pw.print(“Last access:”+date+”<br>”);
hs.setAttribute(“date”, date);
pw.println(“Current date:”+date);
}
}