PROGRAM 1
PROGRAM TO PRINT HELLO & WELCOME TO JAVA.
class himanshu1 { public static void main (String args[]) {[Link]("hello ..its me himanshu........"); [Link]("HEY WELCOME TO JAVA"); }
OUTPUT
PROGRAM 2
PROGRAM TO IMPLEMENT BUFFER READER.
import [Link].*; class himanshu3 { public static void main(String args[]) { InputStreamReader a=new InputStreamReader([Link]); BufferedReader br=new BufferedReader(a); String name; [Link]("Enter your name"); try { name=[Link]();
[Link]("YOUR NAME IS"); [Link](name); } catch(IOException e) { [Link]("error"); } }}
OUTPUT
PROGRAM 3
PROGRAM TO IMPLEMENT COMMAND LINE.
class command_line { public static void main(String args[]) { String a,b,s; a=args[0]; b=args[1]; [Link](a+" "+b); } }
OUTPUT
PROGRAM 4
PROGRAM TO IMPLEMENT DATA INPUT STREAM.
import [Link].*;
class dis { public static void main(String args[]) throws IOException { DataInputStream d=new DataInputStream([Link]); String s; int a,b,c; [Link](" Enter 1st no.- "); s=[Link](); a=[Link](s); [Link](" Enter 2nd no.- "); s=[Link](); b=[Link](s);
c=a+b;
[Link](" addition is= "+c); } }
OUTPUT
PROGRAM 5
PROGRAM TO IMPLEMENT DATA INPUT STREAM.
package p1; public class root { int a,b,c; float r1,r2; root() { a=1;b=3;c=2; } public void cal() { int d; d=b*b-4*a*c; r1=(float)((-b)+[Link](d))/(2*a); r2=(float)((-b)-[Link](d))/(2*a);
[Link]("the roots of equation are:"+r1 +"and" +r2); } } package p2; public class area { float b,h; area() { b=2;h=3;
} public void cal1() { float area; area=(float)(0.5)*b*h;
[Link]("the area of triangle is:"+area); } }
//MAIN import p1.*; import p2.*; class sumit { public static void main(String args[]) { area a= new area(); root b=new root(); a.cal1(); [Link](); } }
OUTPUT
PROGRAM 6
PROGRAM TO IMPLEMENT THREADS.
class A extends Thread { public void run() { for(int i=1;i<11;i++) [Link]("table of 2 is" +2*i); } } class B extends Thread { public void run() { for(int j=1;j<11;j++)
[Link]("table of 5 is" +5*j); } } class C extends Thread { public void run() { for(int k=1;k<11;k++) [Link]("table of 10 is" +10*k); } } //MAIN class thread { public static void main(String args[]) { A threadA=new A(); B threadB=new B(); C threadC=new C(); [Link](); [Link]("START A"); [Link](); [Link]("START B"); [Link](); [Link]("START C"); } }
OUTPUT
PROGRAM 7
PROGRAM TO IMPLEMENT LIBRARY MANAGEMENT BY MAKING OBJECTS.
Package pkg; import [Link].*; public class libr { DataInputStream k= new DataInputStream([Link]); public void issue() { try{[Link]("book name??"); String book =[Link](); [Link]("library id??"); int lid=[Link]([Link]()); [Link](book); [Link](" has been issued to idno. "+lid+" for 15 days"); } catch(Exception e) {[Link]("error"); } } public void retn() { try{ [Link]("book id"); int id; id = [Link]([Link]()); [Link]("Enter no. of day after due"); int days; days=[Link]([Link]()); int fine= days*2; [Link]("FINE Rs."+fine); } catch(Exception e) {[Link]("error");} } } //MAIN import pkg.*; import [Link].*; class library { public static void main(String args[]) { DataInputStream k= new DataInputStream([Link]);
try{ [Link]("\t\t\t WELCOME TO A.S.E.T. LIBRARY"); [Link]("\n\n\tENTER YOUR NAME"); String book =[Link](); int select; intbookcount=500; DataInputStream a= new DataInputStream([Link]); int lid; do{ [Link]("\t\t\t**ENTER YOUR CHOICE**\n\t\[Link] BOOK \n\t\[Link] BOOK\n\t\[Link] TOTAL NUMBER OF BOOKS"); select=[Link]([Link]()); libr l = new libr(); switch(select) { case 1: [Link](); bookcount--; [Link]("BOOKS LEFT\t\t"+bookcount); break; case 2: [Link](); bookcount++; [Link]("BOOKS LEFT\t"+bookcount); break; case 3: [Link]("TOTAL NUMBER OF BOOKS IS\t\t"+bookcount); break; default: [Link]("\nWRONG CHOICE"); } [Link]("\nTO GET THE OPTIONS AGAIN PRESS 5"); [Link]("\n\nTO EXIT FROM PROGRAM TYPE EXIT"); lid=[Link]([Link]()); }
while(lid==5);} catch(Exception e) { [Link]("\nTHANK YOU FOR VISITING"); } } }
OUTPUT
PROGRAM 8
PROGRAM TO IMPLEMENT TWO INTERFACES IN A CLASS.
import [Link].*; interface i { void u(String nme); void v(int marks); } interface j { void w(int age); } class a implements i { public void u(String nm) { [Link]("the name of the owner is "+nm); } public void v(int marks) { [Link]("the marks in linux are "+marks+" out of 100"); } public void w(int age) { [Link]("the age of the student is "+ age); } } class himanshu8 { public static void main(String args[]) { String name; BufferedReader br,br1,br2; br = new BufferedReader( new InputStreamReader( [Link] ) ); br1=new BufferedReader( new InputStreamReader( [Link] ) ); br1=new BufferedReader( new InputStreamReader( [Link] ) ); [Link]("enter the following "); [Link]("1) name of the student"); [Link]("2) marks in linux out of 100 "); [Link]("3) age of the student"); try{
name= [Link](); String input = [Link](); Integer number = [Link](input); String in = [Link](); Integer num= [Link](in); a o1=new a(); o1.u(name); o1.v(number); o1.w(num); } catch(IOException e) {[Link]("error");} } }
OUTPUT
PROGRAM 9
PROGRAM TO DRAW HUMAN FACE.
import import import import
[Link].*; [Link].*; [Link].*; [Link].*;
//<applet code=humanface width=300 height=300></applet> public class humanface extends Applet { public void init() { setBackground([Link]); } public void paint(Graphics g) { Font f=new Font("Arial",[Link],30); [Link](f); [Link](40,40,120,150); //head [Link](57,75,30,20); //left eye [Link](110,75,30,20);//right eye [Link](68, 81,10,10); // pupil left [Link](121, 81,10,10); // pupil right [Link](85, 100,30,30); // nose [Link](25, 92,15,30); // left ear [Link](160,90,15,30); // right ear [Link]([Link]); [Link](60,125,80,40,180,180); [Link]([Link]); [Link]("Human Face",30,20); [Link](" welcome to graphics programming " ,20,250); }
OUTPUT