0% found this document useful (0 votes)
141 views

VIMP Java Programms by Rajan Sir

Uploaded by

temptaccforclg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views

VIMP Java Programms by Rajan Sir

Uploaded by

temptaccforclg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

1
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

WRITE A PROGRAM TO PRINT EVEN AND ODD FROM 1 TO 50

public class Program


{
public static void main(String[] args)
{
for(int i=2;i<=50;i=i+2)
{
System.out.println(i+" is even");
}
for(int i=1;i<=50;i=i+2)
{
System.out.println(i+" is odd");
}

}
}

2
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Write a Program to print FIBBONACCI SERIES

public class Program


{
public static void main(String[] args)
{
int n1=0,n2=1,n3,i,count=10;
System.out.print (n1+" "+n2);
for(i=2;i<count;++i)
{
n3=n1+n2;
System.out.print(" "+n3);
n1=n2;
n2=n3;
}

}
}

3
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Write a Program to check if number is PRIME NUMBER OR NOT

public class Program


{
public static void main(String[] args)
{
int i,m,flag=0;
int n=31;
m=n/2;
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
System.out.println(n+" is not prime number");
flag=1;
break;
}
}
if(flag==0)
{
System.out.println(n+" is prime number");

4
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

}
}

5
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Write a Program to Print Factorial of a Number

class FactorialExample{
public static void main(String args[]){

int i,fact=1;

int number=5;//It is the number to calculate factorial

for(i=1;i<=number;i++){

fact=fact*i;

}
System.out.println("Factorial of "+number+" is: "+fact);

6
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Write a Program to REVERSE A NUMBER

public class Program


{
public static void main(String[] args)
{
int number=1234,reverse=0;
System.out.println("The original number is :"+number);
while(number !=0)
{
int remainder=number%10;
reverse =reverse*10+remainder;
number=number/10;
}
System.out.println("The reverce number is : "+reverse);

}
}

7
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Write a Program to check if number is PALINDROME NUMBER

public class Program


{
public static void main(String[] args)
{
int number=212,reverse=0;
int temp=number;
while(number !=0)
{
int remainder=number%10;
reverse =reverse*10+remainder;
number=number/10;
}
if(temp==reverse)
{
System.out.println(temp+" number is pallindrome");
}
else
{
System.out.println(temp+" number is non pallindrome");
}
8
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

}
}

9
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Write a Program to print SUM OF DIGIT

public class Program


{
public static void main(String[] args)
{
int number=54,sum=0;

while(number !=0)
{
int remainder=number%10;
sum =sum+remainder;
number=number/10;
}
System.out.println("The sum of digit is : "+sum);

}
}

10
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Write a Program to check if number is AMGSTRONG NUMBER

public class Program


{
public static void main(String[] args)
{
int number=153,amg=0;
int temp=number;
while(number !=0)
{
int remainder=number%10;
amg =amg+(remainder*remainder*remainder);
number=number/10;
}
if(temp==amg)
{
System.out.println(temp+" is amgstrong");

}
else
{
System.out.println(temp+" is not amgstrong");
11
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

}
}
}

12
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Write a Program to Draw Concentric Circles.

import java.awt.*;
import java.applet.*;
public class ConcentricCircles2 extends Applet
{
String str = "Concentric Circles";
public void paint(Graphics g)
{
g.setColor(Color.pink);
g.drawOval(20,20,45,45);

g.setColor(Color.red);
g.drawOval(10,10,65,65);

g.setColor(Color.green);
g.drawOval(30,30,25,25);

g.setColor(Color.black);
g.setFont(new Font("Times New Roman",Font.BOLD|Font.ITALIC,20));
g.drawString(str,100,20);
}
}
13
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

/* <applet code=ConcentricCircles2 width=300 height=300>


</applet>
*/

14
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q1 . Write a program to sort the elements of an array in ascending order.

public class ascending {

public static void main(String[] args) {

int i;

int j;

int temp;

int[] a = {30,20,10,40,50};

System.out.println("Array before sorting : ");

for(i=0;i<=4;i++){

System.out.println(a[i]);

for(i=0;i<=3;i++){

for(j=0;j<=3-i;j++){

if(a[j]>a[j+1]){

temp = a[j]; // logic to swap numbers

a[j] = a[j+1];

a[j+1] = temp;

System.out.println("Array after sorting");

15
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions
for(i=0;i<=4;i++){

System.out.println(a[i]);

16
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q2 . Write a program to show the Hierarchical inheritance.

class A

public void methodA()

System.out.println("method of Class A");

class B extends A

public void methodB()

System.out.println("method of Class B");

class C extends A

public void methodC()

System.out.println("method of Class C");

class D extends A

public void methodD()


17
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

System.out.println("method of Class D");

class JavaExample

public static void main(String args[])

B obj1 = new B();

C obj2 = new C();

D obj3 = new D();

//All classes can access the method of class A

obj1.methodA();

obj2.methodA();

obj3.methodA();

18
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q3 . Develop and Interest Interface which contains Simple Interest and Compound Interest methods
and static final field of rate 25%. Write a class to implement those methods.

import java.util.Scanner;

import static java.lang.Math.pow;

int roi=25;

public void simpleInterest(float principle,float time);

public void compoundInterest(float principle,float time);

public class InterestTest implements Interest

public void simpleInterest(float principle,float time)

float si = (principle*roi*time)/100;

System.out.println("Simple interested calculate by program is : " + si);

public void compoundInterest(float principle,float time)

double ci = principle * (Math.pow((1.0 +(roi/100)), time)) - principle; System.out.println("Compound


interested calculate by program is : " + ci);

public static void main(String args[])

InterestTest i1 = new InterestTest(); i1.simpleInterest(1000,2); i1.compoundInterest(1000,2);

}}

19
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q5 . Write a program to print the sum, difference and product of two complex numbers by creating a
class named "Complex" with separate methods for each operation whose real and imaginary parts are
entered by user.

import java.util.*;

class Complex

int real, imaginary;

Complex()

Complex(int tempReal, int tempImaginary)

real = tempReal;

imaginary = tempImaginary;

Complex addComp(Complex C1, Complex C2)

Complex temp = new Complex();

temp.real = C1.real + C2.real;

temp.imaginary = C1.imaginary + C2.imaginary;

Complex subtractComp(Complex C1, Complex C2)

20
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Complex temp = new Complex();

temp.real = C1.real - C2.real;

temp.imaginary = C1.imaginary - C2.imaginary;

Complex productComp(Complex C1, Complex C2)

Complex temp = new Complex();

temp.real = ((C1.real*C2.real)-(C1.imaginary*C2.imaginary));
temp.imaginary = ((C1.real*C2.imaginary) + (C1.imaginary*C2.real));

return temp;

void printComplexNumber()

System.out.println("Complex number: " + real + " + " + imaginary + "i");

public class Main

public static void main(String[] args)

Complex C1 = new Complex(3, 2);

C1.printComplexNumber();

Complex C2 = new Complex(9, 5);

C2.printComplexNumber();

Complex C3 = new Complex();

C3 = C3.addComp(C1, C2);

21
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

System.out.print("Sum of ");

C3.printComplexNumber();

C3 = C3.subtractComp(C1, C2);

System.out.print("Difference of ");

C3.printComplexNumber();

C3 = C3.productComp(C1, C2);

System.out.print("product of "); C3.printComplexNumber();

OUTPUT:

Complex number: 3 + 2i

Complex number: 9 + 5i

Sum of Complex number: 12 + 7i

Difference of Complex number: -6 + -3i

product of Complex number: 17 + 33i

22
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q5 . Explain thread methods to set and get priority.

// via help of getPriority() and setPriority() method

import java.lang.*;

class ThreadDemo extends Thread {

public void run()

System.out.println("Inside run method");

public static void main(String[] args)

ThreadDemo t1 = new ThreadDemo();

ThreadDemo t2 = new ThreadDemo();

System.out.println("t1 thread priority : " + t1.getPriority());

System.out.println("t2 thread priority : " + t2.getPriority());

t1.setPriority(2);

t2.setPriority(5);

System.out.println("t1 thread priority : "+ t1.getPriority());

System.out.println("t2 thread priority : "+ t2.getPriority());

System.out.println( "Currently Executing Thread : " + Thread.currentThread().getName());

System.out.println( "Main thread priority : " + Thread.currentThread().getPriority());

Thread.currentThread().setPriority(10);

System.out.println("Main thread priority : " + Thread.currentThread().getPriority());

}
23
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

OUTPUT:

t1 thread priority : 5 t2 thread priority : 5


t1 thread priority : 2 t2 thread priority : 5
Currently Executing Thread : main Main thread priority : 5

Main thread priority : 10

24
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q6 . Write a program to draw a chessboard in Java Applet.

import java.applet.*;

import java.awt.*;

public class chessBoard extends Applet{

int x;

int y;

int i;

int j;

public void paint(Graphics g){

for(i=1;i<=8;i++){

if(i==1){

y= 50;

x = 50;

for(j=1;j<=8;j++){

if((i%2)==(j%2)){

g.setColor(Color.WHITE);

else{

g.setColor(Color.BLACK);

g.fillRect(x, y, 50, 50);

// increse x cordinate for aech box

25
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions
x = x + 50;

// increment y after every row

y = y + 50;

HTML CODE :

<html>

<head>

<title>

App

</title>

</head>

<body>

<applet code="chessBoard.class" width="500" height="500">

</applet>

</body>

</html>

26
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

OUTPUT

27
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q7 . Write a program to create a user defined exception in java.

import java.lang.Exception;

import java.io.*;

class myException extends Exception

myException(String msg)

super(msg);

class agetest

public static void main(String args[])

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

//Scanner class is also valid

try

System.out.println("enter the age : ");

int n=Integer.parseInt(br.readLine());

if(n < 18 )

throw new myException("Invalid Age"); //user defined exception

else

System.out.println("Valid age");

}
28
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

catch(myException e)

System.out.println(e.getMessage());

catch(IOException ie)

{}

29
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q9 . Write a program to print all the Armstrong numbers from 0 to 999

class armstrong{

public static void main(String[] args) {

int i,a;

int lenght;

int org;

int armstrong;

int num;

System.out.println("Armstrong numbers between 1 to 999 are : ");

for(i=1;i<=999;i++){

armstrong = 0;

lenght = 0;

org = i;

num = i;

while(num!=0){

lenght ++;

num = num / 10;

num = org;

while(num!=0){

a = num % 10;

armstrong = armstrong + (int)(Math.pow(a,lenght));

num = num / 10;

30
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions
}

if(org == armstrong){

System.out.println(armstrong);

OUTPUT :

Armstrong numbers between 1 to 999 are :

153

370

371

407

31
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q10 . Write a program to read a file (Use character stream)

import java.io.FileWriter;

import java.io.IOException;

public class IOStreamsExample {

public static void main(String args[]) throws IOException {

File file = new File("D:/myFile.txt");

FileReader reader = new FileReader(file);

char chars[] = new char[(int) file.length()];

reader.read(chars);

File out = new File("D:/CopyOfmyFile.txt");

FileWriter writer = new FileWriter(out);

//Writing data to the file

writer.write(chars);

writer.flush();

System.out.println("Data successfully written in the specified file");

32
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q11 Design an applet to perform all arithmetic operations and display the result
by using labels. textboxes and buttons. (W-22)

import java.applet.*;

import java.awt.*;

import java.awt.event.*;

public class arithmetic extends Applet implements ActionListener{

// creating all required components

// creating labels

Label l1 = new Label("Number 1 : ");

Label l2 = new Label("Number 2 : ");

Label l3 = new Label("Result : ");

// creating TextFields

TextField t1 = new TextField(20);

TextField t2 = new TextField(20);

TextField t3 = new TextField(20);

// creating buttons

Button b1 = new Button("Add +");

Button b2 = new Button("Sub -");

Button b3 = new Button("Mul *");

Button b4 = new Button("Div /");

33
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

public void init(){

// adding all components in applet

add(l1);

add(t1);

add(l2);

add(t2);

add(l3);

add(t3);

add(b1);

add(b2);

add(b3);

add(b4);

b1.addActionListener(this);

b2.addActionListener(this);

b3.addActionListener(this);

b4.addActionListener(this);

public void actionPerformed(ActionEvent e){

34
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions
// getting input numbers in n1 and n2 by converting them in
integer format

int n1 = Integer.parseInt(t1.getText());

int n2 = Integer.parseInt(t2.getText());

// checking which button is clicked

if(e.getSource()==b1){

// display result in TextField t3

t3.setText(" " + (n1+n2));

else if(e.getSource()==b2){

t3.setText(" " + (n1-n2));

else if(e.getSource()==b3){

t3.setText(" "+(n1*n2));

else if(e.getSource()==b4){

t3.setText(" "+(n1/n2));

HTML CODE :
35
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

<html>

<head>

<title>

App

</title>

</head>

<body>

<applet code="arithmetic.class" width="800" height="800">

</applet>

</body>

</html>

OUTPUT :

36
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

37
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

Q13 .

import java.awt.*;

import java.applet.*;

public class BarChart extends Applet

int n=0;

String label[];

int value[];

public void init()

setBackground(Color.yellow);

try

int n = Integer.parseInt(getParameter("Columns"));

label = new String[n];

value = new int[n];

label[0] = getParameter("label1");

label[1] = getParameter("label2");

38
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions
label[2] = getParameter("label3");

label[3] = getParameter("label4");

value[0] = Integer.parseInt(getParameter("c1"));

value[1] = Integer.parseInt(getParameter("c2"));

value[2] = Integer.parseInt(getParameter("c3"));

value[3] = Integer.parseInt(getParameter("c4"));

catch(NumberFormatException e){}

public void paint(Graphics g)

for(int i=0;i<4;i++)

g.setColor(Color.black);

g.drawString(label[i],20,i*50+30);

g.setColor(Color.red);

g.fillRect(50,i*50+10,value[i],40);

HTML CODE :

39
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

<html>

<head>

<title>APP</title>

</head>

<body>

<applet code="BarChart.class" width="400" height="400">

<param name=c1 value=110>

<param name=c2 value=120>

<param name=c3 value=170>

<param name=c4 value=160>

<param name=label1 value=2011>

<param name=label2 value=2012>

<param name=label3 value=2013>

<param name=label4 value=2014>

<param name=Columns value=4>

</applet>

</body>

</html>

OUTPUT :

40
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428
V2V EdTech LLP | Java (CO/IT/AIML) (22412) | ALL Board Questions

41
YOUTUBE : SUBSCRIBE NOW INSTA : FOLLOW NOW
Download V2V APP on Playstore for more FREE STUDY MATERIAL
Contact No : 9326050669 / 9326881428

You might also like