Java

Program to Create an Application that Represents Biodata Form

Posted on

/* Java Program to Create an Application that Represents Biodata Form */ import java.lang.*; import java.io.*; class EmployeeS { int age, num; String nme, add; void emp_Info(int x) { try { num = x; DataInputStream dts=new DataInputStream(System.in); System.out.println(“Enter Your Name:”); nme = dts.readLine(); System.out.println(“\nEnter Your Address:”); add = dts.readLine(); System.out.println(“\nEnter Your Age:”); age = Integer.parseInt(dts.readLine()); […]

Java

Program to Draw a Concentric Circles with Random Colors

Posted on

/*** Java Program to Draw a Concentric Circles with Random Colors ***/ Java Source Code import java.awt.*; import java.applet.*; import java.util.*; public class cir_c extends Applet { public void paint(Graphics g) { Random rg = new Random(); for (int i=1; i<=3; i++) { int r = rg.nextInt(255); int gr = rg.nextInt(255); int b = rg.nextInt(255); […]

Java

Program to Draw a Smiling Face

Posted on

/**** Java Program to Draw a Smiling Face ****/ import java.applet.*; import java.awt.*; import java.awt.event.*; /*<applet code=”smile.class” height=200 width=200></applet>*/; public class smile extends Applet { public void paint(Graphics g) { g.drawOval(250,250,300,300); g.drawOval(310,320,30,30); g.drawOval(440,320,30,30); g.drawLine(390,350,390,390); g.drawArc(330,400,140,90,0,-180); } } Output:

Java

Program to Handle any Three In-built Exceptions

Posted on

/**** Java Program to Handle any Three In-built Exceptions ****/ class checkExcept { public void add() { try { int y = 20,z = 0; int x = y/z; System.out.println(x); System.out.println(“working”); } catch(ArithmeticException a) { System.out.println(“error”); } catch(SecurityException a2) { System.out.println(“error”); } catch(ArrayStoreException a1) { } catch(Exception x) { System.out.println(x.getMessage()); } finally { System.out.println(“finaly”); } […]

Java

Program to Implement Multithreading

Posted on

/**** Java Program to Implement Multithreading ****/ import java.lang.*; class aa extends Thread { public void run() { for(int i=0;i<4;i++) { try { if(i == 3) { sleep(4000); } } catch(Exception x) { } System.out.println(i); } System.out.println(” i finished “); } } class bb extends Thread { public void run() { for(int i=0; i<4; i++) […]

Java

Program to Implement Overriding of Methods

Posted on

/**** Java Program to Implement Overriding of Methods ****/ class bca { int d; void get(int x) { d = x; } void display() { System.out.println(“Bca = ” + d); } } class mca extends bca { int y; mca(int m, int y) { get(m); this.y = y; } void display() { System.out.println(“Bca = ” […]

Java

Program to Implement this and super Keyword

Posted on

/**** Java Program to Implement this and super Keyword ****/ class vehicle { int id; String color; vehicle(int regno,String color) { id = regno; this.color = color; } } class vchl extends vehicle { int id; String color; vchl(int i1,int i2,String s1,String s2) { super(i2,s2); id = i1; color = s1; } void pdata() { […]

Java

Program to Implement the Concept of Inheritance

Posted on

/**** Java Program to Implement the Concept of Inheritance ****/ class prnt { int a, s; void show() { System.out.println(“Fathre name: Mr. Roshan Lal”); } } class radha extends prnt { void get(int x,int y) { a = x; s = y; } void show1() { show(); System.out.println(“Std name: Radha”); System.out.println(“age:” + a); System.out.println(“salary:” + […]