BCA 4507L Practical Assignment
BCA 4507L Practical Assignment
BCA 4507L Practical Assignment
Q1). Write a program to evaluate simple interest of given principle, rate and time.
Q2). Write a program to calculate the hypotenuse of right angled triangle when other sides of
the triangle are given.
Q3). Write a class with a static method that returns the maximum value of three given integers.
Write another class with the main method call the static method to print the maximum values
for two sets of integer values(say { 5 , 2 , 10},{75 , 20 , 89}).
Q4). Write a program to calculate the area of Rectangle and Circle by overloading the area
method.
Q5). The employee list for a company contains employee code , name , designation , and basic
pay. The employee is given a house rent allowance (HRA) of 10% of the basic pay and dearness
allowance(DA) of 45% of basic pay. The total pay of the employee is calculated as basic pay
+ HRA + DA. Write a class to define the details of the employee. Write a constructor to assign
the required initial values. Add a method to calculate HRA , DA and total pay and print them
out. Write another class with a main method. Create objects for three different employees and
calculate the HRA, DA and total pay.
Q6). Create a complex number class. The class should have a constructor and methods to add
, subtract and multiply two complex numbers and to return the real and imaginary parts.
Q7). Write a java program to concept three numbers by using command line arguments and
display maximum number out of three numbers using conditional operator.
Q9). Write a program to display prime numbers between 1 to 100. Prime number has to be
calculated through a method which is part of another class. Main method class will be different
.Object will be created from main method class and call the prime number method to display
prime numbers.
Q10. Write a java program to display powers of 2 i.e. 2,4,8,16 to 1024 using bitwise operators.
Q11). Write a java program to display the full pyramid triangle.
Q12). Write a java program to accept a string from the user and count individual and total
vowels from that string.
Q13). Write a java program which will accept string from the user and will check whether the
string is palindrome or not.
Q14). Write a java program which will accept 5 city names from the user and store them in a
String array object and sort them alphabetically and display them.
Q15). Write a java program which will create a student class with rollno and marks fields.
Accept the values for 3 students from the user. Use constructors and proper methods to initialize
and to sort an array object on the basic of marks field of Student class.
Q16).Create a class called NumberData that accept any array of the five numbers. Create a sub
class called Numplay which provides methods for followings:
1. Display numbers entered.
2. Sum of the Number.
3. Average of the numbers.
4. Maximum of the numbers.
5. Minimum of the numbers.
Q17). Write a program to find sum and multiplication of two matrices of 3*3.
Q18). Imagine a publishing company that markets both and audiocassette version of its works.
Create a class publication that stores the title(a string) and price(type float) of publication. From
this class, derive two classes: book , which adds a page count (type int), and tape , which adds
a playing time in minutes(type float). Each of these three classes should have a getdata()
function to get data from the user as the keyword , and putdata function to display its data.
Write a main() program to test the book of and tape classes by creating instance of them asking
, the user to fill in data with getdata() and then displaying data with putdata(). Add a base class
sales that holds an array of three float so that it can record the dollar sales of a particular
publication for the last three months. Include a getdata() function to get three sales amounts
from the user , and putdata() function to display the sales figures. After the book and tape
classes they are derived from both publication and sales. An object of class book or tape should
input and output sales data along with its other data. Main() function should create a book
object and a tape object and exercise their input/output capabilities.
Q19).Write a java program that will accept a list of numbers through the command line
argument. If any entered number is odd so it should throw the customer exception with
meaningful message.
Q20). A method named add has one argument that is an array of strings. It converts these to
double values and returns their sum. The method generates to RangeException, if an array
element is not between 1 to 100 or NumberFormatException if an element is incorrectly
formatted. Write a program that illustrates how to declare and use this method. Include a throw
a clause in method declaration to indicate that these problems can occur and also included
finally clause to thank you an user for using the program.
Q21). Write an application that converts between meters and centimeters. Its first commandline
argument is a numer second command line argument is “centimeter” or “meter”. If the
arguments equals “centimeter” displays a string reporting the equivalent numbers of meters. If
this arguments equals “meters” , display a string reporting the equivalent number of centimeter.
If unit is not given properly then generate custome exception Unitformateexception. If first
argument is not proper format then generate numberformatexception. Generate other exception
as per requirements. (1 meter = 100 centimeter)
Q22). Write a program that takes a string from the user and validate it. The string should be at
least 5 characters and should contain at least one digit. Display an appropriate valid message.
Q23). Write a program that demonstrates the instanceof operator. Declare interfaces I1 and I2.
Interface I3 extends both of these interfaces. Also declares interface I4. Class X implements
I3. Class W extends X and implements I4. Create an object of class W. Use the instanceof
operator to test if that object implements each of the interfaces and is of type X.
Q24). The abstract Fruit class has four subclasses named Apple , Banana , Orange and
Strawberry. Write an application the demonstrates how to establish this class hierarchy.
Declare one instance variable of type string that indicates the color of fruits. Create and display
instances of these objects. Overrides toString() method of object to return a string with the
name of the fruit and its color.
Q25). Write a java program which demonstrates the concept of method overriding. An abstract
class Shape contains the method area() which returns an int value. Square and Rectangle both
are subclasses of the abstract class Shape. Square and Rectangle classes constructor contain
one and two arguments respectively for initializing their instance variables. Both the classes
will override the area() method declared in the super class Shape. Program should calculate the
area of the Square and Rectangle class it should also display the area along with the value of
instance variables of the Square and Rectangle class.
Q26). write an interface called numbers, with a method int process(int x, int y).Write a class
called sum, in which the method process finds the sum of two numbers and return an int value.
Write another class called average, in which the process method finds the average of the two
numbers and returns an int.
Q27).write a java class called sum that finds the sum of all numbers from 1 upto a given number
n. this class is contained in the sub directory name Addition , under the current directort where
all other java program file are stored. Write package statement inside the class sum and imports
it in another file and display the summation of numbers.
Q28). Write a java class called facto that finds the factorial of all numbers from 1 Upto a given
number n. This class is contained in the in the sub directory named factorial, under the current
directory where all other java program files are stored. Write a package statement inside the
class facto and imports it in another file and display the factorial of all the numbers.
Q-29)Write an application that starts 3 threads.Each thread is instantiated from the same class
and displays a message.First thread should display the message “CORE JAVA EXAM” every
300 ms.Second thread should display “SY BCA EXAM” every 500 ms. Third thread
should display “UNIVERSITY EXAM” every 400 ms.Create the threads using Runnable
interface.
Q-30) Create two threads, one thread should print odd numbers between x to y (inclusive) and
second should print even numbers between them. Values of x and y should be user given. Main
thread should wait for thread to be finished and afterwards it should print the message “Threads
Completed”. Create threads with the help of Thread class.
Q-31)Write a java program to create 3 threads using Thread class. Three threads should
calculate the sum of 1 to 5, 6 to 10 and 11 to 15 respectively. After all thread finishes main
thread should print the sum and average.
Q-32) Write an applet which receives three numerical values as its parameters and display the
addition, subtraction and multiplication of all three values and also display those three values.
Q-33) Write an applet program which will draw a vertical bar of 13 different colors.
Q-34)Write an applet program which will draw a Horizontal bar of 13 different colors.
Q-35)Write a java applet program to draw a smile.
Q36)Write a java program to display a circle always in the center of the screen and fill it with
the red color.