Sie sind auf Seite 1von 7

BANARSIDAS CHANDIWALA INSTITUTE OF INFORMATION

TECHNOLOGY
(Affiliated To GGSIP University)

List of Practical

Java Programming

MCA-253

1.) Write a program that will display the message Weight of bundle5Kgs in a constructor and display the weight in kilograms and grams.
2.) Write a Java Program that will contain two Arrays. In the First array
store the following:
a. Chips
b. Apples
c. Mangoes
d. Towels
e. Room Freshner
f. Hangers
g. Pens
h. CornFlakes
i. Oats
And Store the following price of each product in the second Array:
a.
b.
c.
d.
e.
f.
g.
h.
i.

10
20
40
400
400
150
50
20
25

Write a method that will display the products with their corresponding
prices.
3.) Write a Java Program to display a four by four identity matrix.
4.) Write a Java Program to :
a. Test equality between two strings

b. Concatenate The appendage will come after me to one of the


Strings
c. Find the length of the Strings
d. Replace the Is in the strings with zs
e. Convert one of the strings to upper case.
5.) Write a program that has overloaded methods. The first method
should accept no arguments, the second method will accept one string
and the third method will accept a string and an integer. The first
method should display the messageRose is beautiful flower twice.
The second method should display the message The sunflower is a
beautiful flower. Twice.The third method should display the
message Marigold is a beautiful flower Four times.
6.) Create a class called Numeral that accepts an array of ten number.
Create a Sub Class called NumPlay which has a menu as follows:
a. Display Numbers Entered
b. Sum of the Numbers
c. Average of the Numbers
d. Maximum of Numbers
e. Minimum of Numbers
7.) Create an abstract class Shape to describe a shape with two
dimensions. Define a method to display the area of shape. Create two
subclasses: Rectangle and Triangle. Call the display function using
reference variable of the class Shape.
8.) Define an Exception called NoMatchException that is thrown when
a string is not equal to India. Write a program that uses this
exception.

9.) Create a java program to...


a.Create a base class called Shape.It should contain two
methods getCoord() and showCoord() to accept x and y
coordinates and to display the same respectively.
b.Create a sub class called Rect. It should also contain a
method to display the length and breadth of the rectangle called
showCoord()
In the main method , execute the showCoord() method of Rect class
by applying the dynamic method dispatch concept.

Create a class called Message to contain method disp(). This method


accepts a string argument and displays the same. It should wait for
1000 mililseconds, and print End of Message
10.Create a class Sender which creates threads within its
constructor and start them. The constructor accepts a Message
object and a String as parameters.
Create a class SynchTest which creates objects of Sender classs. With
different strings.The program should terminate after this.
Use Synchronized block to obtain output as follows:
Message: Somestring
End of message
Message : Some String
End of message
Message : Some String
End of message

11.Write a program which generates following types of exceptions.


Demonstrate how these exceptions are handled.
ArithmeticExceotion
ArrayIndexOutOfBoundsException
ArrayStoreException
ClassCastException
NegativeArraySizeException
NullPointerException
NumberFormatException
12. Create a user-defined exception named CheckArgument to check the
number of arguments passed through command line. If the number of
arguments is less than five, throw the CheckArgument exception, else
print the addition of all the five numbers.
13.Write a java program that demonstrates how a high-priority thread
using sleep makes way for the low-priority thread to execute.

14.Define an interface named stack with the following methods:-

(i)
(ii)

Push and pop elements from stack.


Check whether the stack is empty or not.

Implement the stack with the help of arrays and if the size of the array
becomes too small to hold the elements, create a new one. Test this
interface by inheriting it in its subclass StackTest.java.
15.Write a Program to accept two parameters on the command line. If
there are no command line arguments entered, the program should
print error message and exit. The program should check if the first file
exists. If so the contents of the file should be copied to the second file.
In case the first parameter is a directory, print message accordingly
and exit. Appropriate error messages should be displayed at all points.
16.Write a program to implement a word count utility, which should
display the count of characters, words and lines. Input can be a disk
file or data read from console.
17.Create an integer array to contain ten numbers Using
RandomAccessFile, Write the array into a file called rand.dat. The
program should read the contents of the rand.dat file backwards. Make
use of try/catch and finally clauses.

18.Create a subpackage called Child whose base package is called Parent.


This should contain a class C1. Class C1 contains a method called
disp() to display a message Inside subpackage Child-C1 Class.
Create a class called ParentTest, which imports the subpackage and
calls the
disp() method of the C1 class.
19.Write a EchoServer and EchoClient Program that displays whatever is
typed in
The server on to the client using Sockets.
20.Use Socket Programming to design a client/server application that
takes the file name as input, checks whether the file exits and displays
its contents(if it exists);

21.Use Socket Proogramming to design a Client/Server application that


takes the password as input and checks whether it is correct. The
program should print the appropriate message.

22.Write a program that displays the system properties.


23.Create a sample TCP chat application where client and server can chat
with each other.

24.Write a program to display the current data and time. The program
should also determine whether the current year is leap year or not. Use
GregorianCalendar Class.
25.Create an applet to obtain a figure as :
1.) The background color for the applet should be set as white.
2.) The text should be written in Helvetica font, style should be
bold and size should be 20. The color of the text should be
black.
3.) Make a Man with head in red color, the body in orange, hands
in green and legs in blue.
26.Write an applet that creates a working version of Fifteen Puzzle The
Puzzle contains a grid with four rows and four columns. The cells of
the grid are filled with numbers from 1 to 15, leaving one cell empty.
On Clicking the mouse on a cell adjacent to the empty cell, the
number in the cell moves to the empty cells. The puzzle is completed
when the user manages the numbers in the cells in ascending order.
27.Write an animation applet that makes an image appear from left to
right, in stages.

28.Create an applet that lets the user adjust the background color, Provide
three scrollbars in your applet, one each for the three base colors, red,
green and blue.

29.Write a complete Text Editor with all the basic functionalities.

30.Mr. Ram has shares of about 200 companies. He needs an application


to maintain the details of these shares.The database consists of the
following tables.
Master Table
Column

Datatype

Description

ShareId

Number(3)

CompName
NoOfShares

Varchar2(20)
Number(4)

PurRate

Number(6,2)

PurDate

Date

CurrRate

Number(6,2)

Unique number for each


row in this table
Name of the Company
Number of shares of the
company held
Rate at which each
share was purchased.
Date on which purchase
was made
Current rate of each
share

Details Table
Column

Datatype

Description

ShareId

Number(3)

CertNo
NoOfShares

Varchar2(10)
Number(3)

This description should


be present in Master
table
Certificate Number
Number of shares in the
certificate

FirstHolder

Varchar2(15)

SecondHolder

Varchar2(15)

SecondHolder

Varchar2(15)

1.) Write a program to create above tables.

Number of shares in the


specified certificate.
First Holder of the
share
Second Holder of the
share

2.) Write a program to change the length of CertNo to 13


characters.
3.) Write a program through which insert statements can be given
at runtime.
4.) Write a program to display all the rows of the Master table.
How will you modify it to display all the rows of the details
table?
5.) Design a program interface to delete, update, insert etc. from
the interface.
31.Create an applet with four JButtons. The label for the following
buttons are given below:
1.) Confirm
2.) Input
3.) Option
4.) Exit
The action of clicking one to the button would bring the respective
dialog box on to the screen except the last button.
32.Write a program in beans to draw Spectrum which changes to Vertical
or horizontal on changing its property.
33.Write a program in beans to make an animated juggler.
34.Write a frame application that has an Option Menu. This Menu has
circle, rectangle, filled circle, filled rectangle as their menu items. On
clicking the relevant option respective figures should be drawn.
Enhance the application with mouse drawing.
35.Create two threads. One thread should print odd number and other
should print even number.Sync the threads so that they dont overlap.

Das könnte Ihnen auch gefallen