[Go to site: main page, start]

0% found this document useful (0 votes)
43 views30 pages

BCA Java Practical Examination Guide

The document appears to be a student exam paper containing details of a BCA degree examination for a student. It includes fields for the student's name, registration number, subject, and semester. It also contains instructions for the internal and external examiners and leaves space for the student to provide answers and details of practical work completed for various topics during the semester, with space for signatures and date of examination.

Uploaded by

bagya lakshmi
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)
43 views30 pages

BCA Java Practical Examination Guide

The document appears to be a student exam paper containing details of a BCA degree examination for a student. It includes fields for the student's name, registration number, subject, and semester. It also contains instructions for the internal and external examiners and leaves space for the student to provide answers and details of practical work completed for various topics during the semester, with space for signatures and date of examination.

Uploaded by

bagya lakshmi
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

PAVENDAR BHARATHIDASAN COLLEGE OF ARTS AND SCIENCE

THANJAI NATARAJAN NAGAR,

MATHUR, PUDUKOTTAI ROAD, TIRUCHIRAPPALLI, PINCODE-622515.

DEPARTMENT OF COMPUTER APPLICATION

BCA DEGREE EXAMINATION

NAME : ________________________________

[Link] : ________________________________

SUBJECT : ________________________________

SEMESTER : ________________________________
PAVENDAR BHARATHIDASAN COLLEGE OF ARTS AND SCIENCE

THANJAI NATARAJAN NAGAR,

MATHUR, PUDUKOTTAI ROAD, TIRUCHIRAPPALLI, PINCODE-622515.

DEPARTMENT OF COMPUTER APPLICATION

Certified that this bonafide recorded or the _______________ practical work done
by ____________________ for ___________ semester in the subject ___________________
During the academic year ______________

Register No:___________________________

STAFF INCHARGE HEAD OF THE DEPARTMENT

Submitted for the practical examination held on ___________________

INTERNAL EXAMINER EXTERNAL EXAMINER


INDEX

[Link] DATE TITLE PAGE NO SIGNATURE

1 Sort the given numbers using arrays

2 FIND and REPLACE operations

3 Calculator to perform basic arithmetic


operations

4 Area of a rectangle

5 Student’s percentage and grade

6 Draw circle or triangle or square

7 Multiple inheritance

8 Create threads and assign priorities

9 Develop an applet to play multiple audio


clip

10 Create a window with three check boxes


SORT THE GIVEN NUMBER USING ARRAYS

[Link]

import [Link]. * ;
class sort
{
public static void main ( String args []) throws IOException
{
InputStreamReader in = new InputStreamReader ( [Link] ) ;
BufferedReader br =new BufferedReader ( in ) ;
int a[]= new int [ 20 ] ;
int i , j , n , temp ;
[Link] ( " Enter value for n : " );
n = [Link] ( [Link] ( ) ) ;
for ( i = 1 ; i <=n ; i ++ )

a[i] = [Link] ( [Link] ());


for ( i = 1 ; i < n ; i ++ )
{
for ( j=i + 1 ; j <=n ; j++ )
{
if(a [ i ] > a [ j ] )
{
temp = a[i] ;
a [ i ] =a[j] ;
a[j] = temp ;
}
}
}
[Link] ( " Ascending order is " ) ;
for (i =1 ; i <= n ; i ++ )
[Link] ( a [ i ] ) ;
[Link] ( " Descending order is " ) ;
for ( i = n ; i >=1 ; i-- )
[Link] ( a [ i ] ) ;
}
}
OUTPUT

C:\Users\BAGYA\Desktop>javac [Link]

C:\Users\BAGYA\Desktop>java sort
Enter value for n : 5
77
89
90
5
56
Ascending order is
5
56
77
89
90
Descending order is
90
89
77
56
5
FIND AND REPLACE OPERATION

[Link]

import [Link] . *;
class findrep
{
public static void main ( String argt [] )
{
Pattern p= [Link] ( " He " ) ;
Matcher m=[Link] ( " He is a doctor . He is a good human being");
if ([Link] ( ) )
{
[Link]([Link] ( " Raja " )) ;
}
else
[Link] ( " not found " ) ;
}
}
OUTPUT

C:\Users\BAGYA\Desktop>javac [Link]

C:\Users\BAGYA\Desktop>java Findrep
Raja is a doctor . Raja is a good human being
CALAULATOR TO PERFORM BASIC ARITHMETIC OPERATIONS

[Link]

import [Link];
import [Link].*;
import [Link];
import [Link];
public class CalculatorApplet extends Applet implements ActionListener {
int i, a, b, c;
TextField t;
char op;
Button ad, sub, mul, div, mod, eql, clr;
Button b0, b1, b2, b3, b4, b5, b6, b7, b8, b9;

public void init() {


setLayout(null);
setBackground([Link]);
setForeground([Link]);
t = new TextField(10);
b0 = new Button("0");
b1 = new Button("1");
b2 = new Button("2");
b3 = new Button("3");
b4 = new Button("4");
b5 = new Button("5");
b6 = new Button("6");
b7 = new Button("7");
b8 = new Button("8");
b9 = new Button("9");
ad = new Button("+");
sub = new Button("-");
mul = new Button("*");
div = new Button("/");
mod = new Button("%");
eql = new Button("=");
clr = new Button("CLR");
add(t);
[Link](100, 70, 150, 25);
add(b0);
[Link](100, 100, 30, 25);
add(b1);
[Link](140, 100, 30, 25);
add(b2);
[Link](180, 100, 30, 25);
add(b3);
[Link](220, 100, 30, 25);
add(b4);
[Link](100, 130, 30, 25);
add(b5);
[Link](140, 130, 30, 25);
add(b6);
[Link](180, 130, 30, 25);
add(b7);
[Link](220, 130, 30, 25);
add(b8);
[Link](100, 160, 30, 25);
add(b9);
[Link](140, 160, 30, 25);
add(ad);
[Link](180, 160, 30, 25);
add(sub);
[Link](220, 160, 30, 25);
add(mul);
[Link](100, 190, 30, 25);
add(div);
[Link](140, 190, 30, 25);
add(mod);
[Link](180, 190, 30, 25);
add(eql);
[Link](220, 190, 30, 25);
add(clr);
[Link](100, 220, 150, 25);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
}
public void paint(Graphics g) {
[Link](70, 50, 200, 210);
}

@Override
public void actionPerformed(ActionEvent ae) {
try {
if ([Link]() == b0) {
[Link]([Link]() + "0");
}
if ([Link]() == b1) {
[Link]([Link]() + "1");
}
if ([Link]() == b2) {
[Link]([Link]() + "2");
}
if ([Link]() == b3) {
[Link]([Link]() + "3");
}
if ([Link]() == b4) {
[Link]([Link]() + "4");
}
if ([Link]() == b5) {
[Link]([Link]() + "5");
}
if ([Link]() == b6) {
[Link]([Link]() + "6");
}
if ([Link]() == b7) {
[Link]([Link]() + "7");
}
if ([Link]() == b8) {
[Link]([Link]() + "8");
}
if ([Link]() == b9) {
[Link]([Link]() + "9");
}
if ([Link]() == ad) {
a = [Link]([Link]());
[Link]("");
op = '+';
}
if ([Link]() == sub) {
a = [Link]([Link]());
[Link]("");
op = '-';
}
if ([Link]() == mul) {
a = [Link]([Link]());
[Link]("");
op = '*';
}
if ([Link]() == div) {
a = [Link]([Link]());
[Link]("");
op = '/';
}
if ([Link]() == mod) {
a = [Link]([Link]());
[Link]("");
op = '%';
}
if ([Link]() == eql) {
b = [Link]([Link]());
if (op == '+') {
c = a + b;
}
if (op == '-') {
c = a - b;
}
if (op == '*') {
c = a * b;
}
if (op == '/') {
c = a / b;
}
if (op == '%') {
c = a % b;
}
[Link]([Link](c));
}
if ([Link]() == clr) {
[Link]("");
}
} catch (Exception ex) {
[Link]("");
}
}
}
[Link]

<html>
<head>
</head>
<body>
<applet code = "[Link]" width = "350" height = "300"></applet>
</body>
</html>
OUTPUT

C:\Users\BAGYA\Desktop>javac [Link]

C:\Users\BAGYA\Desktop>appletviewer [Link]
AREA OF A RECTANGLE

[Link]

import [Link] . *;
class rect
{
double l,b,area ;
rect ( double len , double bre )
{
l = len ;
b = bre ;
}
void cal ( )
{
area = l * b ;
[Link] ( " Area of Rectangle is : " + area ) ;
}
}
class rect1
{
public static void main ( String args [ ] ) throws IOException
{
InputStreamReader in = new InputStreamReader ([Link]) ;
BufferedReader br= new BufferedReader(in) ;
double len , bre ;
[Link] ( " Enter value for length : " ) ;
len = [Link] ( [Link] ( )) ;
[Link] ( " Enter value for breath :" ) ;
bre= [Link] ( [Link] ( ) ) ;
rect r = new rect ( len , bre ) ;
[Link] ( ) ;
}
}
OUTPUT

C:\Users\BAGYA\Desktop>javac [Link]

C:\Users\BAGYA\Desktop>java Rect1
Enter value for length : 4
Enter value for breath :5
Area of Rectangle is : 20.0
STUDENT’S PERCENTAGE AND GRADE

[Link]

import [Link].*;
import [Link] . *;
import [Link].*;
class sort
{
public static void main ( String args[])
{
String name , grade ;
int rno,tam,eng,maj,tot,avg ;
name = args[0] ;
rno = [Link] (args[1]);
tam= [Link] (args[2]) ;
eng = [Link] (args[3]) ;
maj =[Link] (args[4]) ;
tot =tam + eng + maj ;
avg =tot / 3 ;
[Link] ( " Student Details " ) ;
[Link] ( " Name : " + name ) ;
[Link] ( " Roll No : " + rno ) ;
[Link] ( " Tamil : " + tam ) ;
[Link] ( " English : " + eng ) ;
[Link] ( " Major : " + maj);
[Link] ( " Total : " + tot ) ;
[Link] ( " Average : " + avg ) ;
[Link] ( " Grade :");
if ( avg >=80 )
[Link] ( " Distinction " ) ;
else if ( avg >= 60 )
[Link] ( " 1st grade " ) ;
else if ( avg >= 50 )
[Link] ( " 2nd grade " ) ;
else if ( avg >= 40 )
[Link] ( " 3rd grade " ) ;
else
[Link] ( " 4rd grade " ) ;
}
}
OUTPUT

C:\Users\BAGYA\Desktop>java sort bagya 1815 90 60 50


Student Details
Name : bagya
Roll No : 1815
Tamil : 90
English : 60
Major : 50
Total : 200
Average : 66
Grade :
1st grade
DRAW CIRCLE OR TRIANGLE OR SQUARE

[Link]

import [Link] . * ;
import [Link].* ;
//<applet code=[Link]" width="500" height="500">< / applet >
public class App extends Applet
{
public void paint ( Graphics g )
{
int[] x={200 , 300 , 250 , 200 };
int[] y={300 , 300 , 200 , 300 } ;
[Link] ( [Link] ) ;
[Link] ( 200 , 50 , 100 , 100 ) ;
[Link] ( 200 , 350 , 100 , 100 ) ;
[Link] ( x , y , 4 ) ;
}
}

[Link]

<html>
<head>
</head>
<body>
<applet code = "[Link]" width = "480" height = "500"></applet>
</body>
</html>
OUTPUT

C:\Users\BAGYA\Desktop>javac [Link]

C:\Users\BAGYA\Desktop>appletviewer [Link]
MUTIPLE INHERITANCE
[Link]

interface NameId {
void get(String name, int id);
}
interface Dept {
String dept = "Computer", design = "Manager";
}
interface Salary extends NameId, Dept {
void pay(double db1);
}
class Employee implements Salary {
String name;
int id;
double bp, hra, da, ta, lic, np;
@Override
public void get(String name, int id) {
[Link] = name;
[Link] = id;
}
@Override
public void pay(double db1) {
[Link] = db1;
hra = bp * 0.03;
da = bp * 0.05;
ta = bp * 0.02;
lic = bp * 0.03;
np = bp + hra + da + ta - lic;
}
void display() {
[Link](" Department : " + dept);
[Link](" Designation : " + design);
[Link](" Name : " + name);
[Link](" ID : " + id);
[Link](" Basic Pay : " + bp);
[Link]("net pay:" + np);
}
}
public class Demo{
public static void main(String[] args) {
Employee employee = new Employee();
[Link]("roja", 1001);
[Link](50000);
[Link]();
}}
OUTPUT

C:\Users\BAGYA\Desktop>javac [Link]

C:\Users\BAGYA\Desktop>java Demo
Department : Computer
Designation : Manager
Name : mani
ID : 1001
Basic Pay : 50000.0
net pay:53500.0
CREATE THREADS AND ASSIGN PRIORITIES
[Link]

import [Link].*;
import [Link].*;
class A extends Thread
{
public void run()
{
[Link]("Thread A started");
for(int i=1;i<=5;i++)
[Link]("A:"+i);
[Link]("Exited from A");
}
}
class B extends Thread
{
public void run()
{
[Link]("Thread B started");
for(int j=1;j<=5;j++)
[Link]("B:"+j);
[Link]("Exited from B");
}
}
class C extends Thread
{
public void run()
{
[Link]("Thread c started");
for(int k=1;k<=5;k++)
[Link]("Exited from c");
}
}
class sort
{
public static void main(String args[])
{
A ob1=new A();
B ob2=new B();
C ob3=new C();
[Link](Thread.MAX_PRIORITY);
[Link]([Link]()+1);
[Link](Thread.MIN_PRIORITY);
[Link]("A is going to start");
[Link]();
[Link]("B is going to start");
[Link]();
[Link]("C is going to start");
[Link]();
}
}
OUTPUT

C:\Users\BAGYA\Desktop>javac [Link]

C:\Users\BAGYA\Desktop>java Sampthread
A is going to start
B is going to start
Thread A started
Thread B started
C is going to start
B:1
B:2
B:3
B:4
B:5
Exited from B
A:1
Thread c started
Exited from c
Exited from c
Exited from c
Exited from c
Exited from c
A:2
A:3
A:4
A:5
Exited from A
DEVELOP AN APPLET TO PLAY MULTIPLE AUDIO CLIPS
[Link]

import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
//<applet code="[Link]" width=300 height=300”>
//</applet>
public class sort extends Applet implements ActionListener
{
AudioClip s1,s2;
Button b1,b2;
public void init()
{
b1=new Button("Audio1");
b2=new Button("Audio2");
s1=getAudioClip(getCodeBase(),"[Link]");
s2=getAudioClip(getCodeBase(),"[Link]");
add(b1);
add(b2);
[Link](this);
[Link](this);
}
public void actionPerformed(ActionEvent e)
{
if([Link]()==b1)
{
if(s1!=null)
[Link]();
else
repaint();
}
if([Link]()==b2)
{
if(s2!=null)
[Link]();
else
repaint();
}
}
public void paint(Graphics g)
{
showStatus("File not found");
}
}
[Link]

<html>
<head>
</head>
<body>
<applet code = "[Link]" width = "480" height =

"500"></applet>
</body>
</html>
OUTPUT

C:\Users\BAGYA\Desktop>javac [Link]

C:\Users\BAGYA\Desktop>appletviewer [Link]
CREATE A WINDOW WITH THREE CHECK BOXES
[Link]

import [Link].*;
import [Link].*;
import [Link].*;
//<applet code="[Link]" width=500 height=500>
//</applet>
public class checkex10 extends Applet implements ItemListener
{
Checkbox r,g,b;
Color c;
public void init()
{
r=new Checkbox("RED");
g=new Checkbox("GREEN");
b=new Checkbox("BLUE");
add(r);
add(g);
add(b);
[Link](this);
[Link](this);
[Link](this);
}
public void itemStateChanged(ItemEvent e)
{
if([Link]()==r)
{
c=[Link];
[Link](false);
[Link](false);
}
if([Link]()==g)
{
c=[Link];
[Link](false);
[Link](false);
}
if([Link]()==b)
{
c=[Link];
[Link](false);
[Link](false);
}
repaint();
}
public void paint(Graphics g)
{
setBackground(c);
}
}

[Link]

<html>
<head>
</head>
<body>
<applet code = "[Link]" width = "480" height =

"500"></applet>
</body>
</html>
OUTPUT

C:\Users\BAGYA\Desktop>javac [Link]

C:\Users\BAGYA\Desktop>appletviewer [Link]

You might also like