click here

Java Programming

import java.awt.*;
import java.applet.*;



public class app extends Applet
{
 public void paint(Graphics g)
 {
  g.drawString("manoj",20,20);
  }
  }


import java.awt.*;
import java.applet.*;

public class applet1 extends Applet
{
 public void paint(Graphics g)
 {
  g.drawOval(10,10,240,150);
  g.drawOval(150,30,50,50);
   g.drawOval(50,30,50,50);
  g.setColor( Color.blue );
 
                          
  g.fillOval(120,40,10,80);
  g.fillArc(80,100,100,50,180,180);

   //    g.fillArc(80,200,150,80,0,180);
   //    g.drawLine(150,200,150,400);

    g.drawLine(50,50,200,25);
    g.drawLine(50,55,200,30);

    g.drawLine(50,100,200,75);
    g.drawLine(50,105,200,80);

    g.drawLine(90,50,100,90);
    g.drawLine(95,50,105,90);
      g.drawLine(130,45,140,85);
      g.drawLine(135,45,145,85);







  try{
  for(int i=1;i<9;i++)
   {
   Thread.sleep(100);
    g.fillOval(158,39,25,25);  g.fillOval(58,39,25,25);
    repaint();
    }
    }
   catch(Exception e)
    { }
  
  

  }
}
















import java.awt.*;
import java.applet.*;

public class applet3 extends Applet
{
 public void paint(Graphics g)
 {

       g.fillArc(180,200,150,100,0,180);
       g.drawLine(150,200,150,400);

}
}
/*








import java.applet.*;
import java.awt.*;


public class button extends Applet
{
 Button b1,  b2;
 public void init()
  {
   setLayout (new FlowLayout(FlowLayout.LEFT));
   b1 = new Button("button1");
   b2 = new Button("button2");
   add(b1);
   add(b2);
  }

 public void paint(Graphics g)
 {
  g.drawString("manoj",100,100);
  }

 }
 /*
 
 





import java.awt.*;
import java.applet.*;

public class gridlayout extends Applet
{
 static final int n=4;
 public void init()
  {
        setLayout(new GridLayout (n,n));
        setFont(new Font("SansSerif", Font.BLOD, 24));

        for(int i=;i
        {
         for(int j=0;j
          {
           int k=i*n+j;
           if(k>0)
            add(new Button(""+k));
           }
        }
    }
 }

/*






jdbc

import java.sql.*;
class jdbc
{
 public static void main (String a[]) throws SQLException
 {
  try
  {
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection con =  DriverManager.getConnection("jdbc:odbc:manoj");
    Statement st = con.createStatement();
  
  //   ResultSet rs = st.executeQuery(" insert into student values(deepak, 21)"  ) ;
      ResultSet rs = st.executeQuery("select *from student");
    while(rs.next())
     System.out.println(rs.getString(1)+ "   " +rs.getInt(2) );
    }

    catch(Exception e)
     {
      System.out.println("error");}
  }
}




override

class a
{
 int i,j;
 a(int a, int b)
 {
  i=a; j=b;
  }

 void show()
 {
  System.out.print(" i and j " + i + j);
  }
 }

class b extends a
{

 int k;
 b(int a, int b, int c)
 {
  super(a,b);
  k=c;
  }

 void show()
  {
   System.out.print(" k " + k);
   }
}

class overrid
{
 public static void main(String args[])
  {
   b ob = new b(1,2,3);
  ob.show();
  }


 }




import java.io.*;
class read
{
public static void main(String a[])
 throws IOException
 {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str;
   System.out.println("enter q for quit");
    do
     {
     str = br.readLine();
     System.out.println(str);
     } while(!str.equals("q"));
     }
     }




rmi



import java.rmi.*;
interface multiply extends Remote
{
int multiply (int x, int y) throws RemoteException;
}


import java.rmi.*;
import java.rmi.server.*;

public class server extends UnicastRemoteObject implementes multyply
{
public server() throws RemotException{}
public static void main(String a[]) throws Exception
{
System.out.println("server Starts");
server s= new server();
Naming.rebind("server", s);
}
public int multiply(int x1, int y1)
{
return(x1*y1);
}
}






import java.io.*;
import java.rmi.*;
import java.net.*;
public class client
{
public static void main(String a[]) throws Exception
{
InputStreamReader i=new InputStreamReader(System.in);
BufferedReader b1=new BufferedReader(i);
InetAddress ia=InetAddress.getLocalHost();
String url ="rmi://"+"/server";
System.out.println("Remote Method Invocation - Bill Calculation");
multiply m=(multiply)Naming.lookup(url);
System.out.println("Enter the Number of purchaseed");
Sttring temp=b1.readLine();
int a =Integer.parseInt(temp);
System.out.println("Enter the Unit Price");
Strin temp1=b1.readLine();
int b=Integer.parseInt(temp1);
System.out.println("The Total Amount is Rs"+m.multiply(a,b));
}
}



servlet

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class servlet1 extends HttpServlet
{
 public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException   
{
    res.setContentType("text/html");
    PrintWriter Out=res.getWriter();
 
    Out.println("");
    Out.println("");
    Out.println(" please shutdown ur pc ");
    Out.println("");
    Out.println("");
    Out.close();
}
}


class prime
{
public static void main(String args[])
{
System.out.println("The Prime Number -> 1");
System.out.println("The Prime Number -> 2");
for (int i=3;i<=500;i++)
{
int a=0;
for(int j=2;j<=i-1;j++)
{
if(i%j==0)
a=1;
}
if(a==0)
System.out.println("The Prime Number -> "+i);

}
 }
  }





class abc
{
int factorial(int a)
{
return(a<=0?1:a*factorial(a-1));
}
void display(int a)
{
System.out.println("Value of factorial = "+
a);
}
}
class fact
{
public static void main(String arg[])
{
abc p=new abc();
int y=p.factorial(15);
p.display(y);
}
}


dsn

import java.net.*;
import java.io.*;

class dns
{
 public static void main(String a[]) throws Exception
{
 try
{
 InetAddress[] address = InetAddress.getAllByName ("www.gmail.com");
for(int j=0;jSystem.out.println(address[j]);
}
catch(Exception e)
{
System.out.println("Error in catch" +e);
}
}
}







class armstrong extends Thread
{
public void run()
{
System.out.println("Armstrong");
int a,b,r;
for(int i=0;i<=15000;i++)
{
r=0;
a=i;
while(a!=0)
{
b=a%10;
a=a/10;
r=r+b*b*b;
}
if(i==r)
{
System.out.println("Arm number ->  "+i);
}
}
}
}
class arm
{
public static void main(String args[])
{
armstrong a=new armstrong();
a.start();
}
}






import java.awt.*;
import java.applet.*;

public class applet1 extends Applet
{
 public void paint(Graphics g)
 {
  g.drawOval(10,10,240,150);
  g.drawOval(150,30,50,50);
  g.setColor( Color.red );
 
  g.fillOval(150,30,40,40);
  g.fillOval(120,40,10,80);
  g.fillArc(80,100,100,50,180,180);



  for(int i=2;i<6;i++)
  {
   if(i%2==0)
    {
    g.setColor( Color.blue );
    g.fillOval(50,30,40,40);

    }
   g.fillOval(50,30,40,40);
   }

  try{
 
  
    Thread.sleep(200);
    g.fillOval(150,30,40,40);
    repaint();
    }
   catch(Exception e)
    { }
  
  

  }
}
/*








import java.io.*;
class read
{
public static void main(String a[])
 throws IOException
 {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str;
   System.out.println("enter q for quit");
    do
     {
     str = br.readLine();
     System.out.println(str);
     } while(!str.equals("q"));
     }
     }



some Books

Introduction to Java Programming, Comprehensive (8th Edition)

Introduction to Java Programming, Brief Version (7th Edition)

1 comment: