Practical List CJP - 24

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

INDUS INSTITUTE OF TECHNOLOGY AND ENGINEERING

COMPUTER ENGINEERING DEPARTMENT


PRACTICAL LIST
SEMESTER: IV [CE] TERM: Jan-2024
SUBJECT: -Core Java Programming [CE0421]
Wk Class
List of Practical
No. Activity
01 Lab 1 1. Write a program to display “Welcome To Java World”.

2. Write a program to find whether the number is prime or not.

3. Write a program to find a greater number among given three numbers using
a) ternary operator
b) nested if.

4. Write a program to print the Fibonacci series.


02 Lab 2 1. Write a program to find the average of n numbers stored in an Array.

03 Lab 3 1. WAP to replace substring with other substring in the given string.

2. WAP that to sort given strings into alphabetical order.

3. Create a String Buffer with some default string. Append any string to i th
position of original string and display the modified string. Also display the
reverse of modified string.
04 Lab 4 1.a) WAP that declares a class named Person. It should have instance variables
to record name, age and salary. Use new operator to create a Person object. Set
and display its instance variables.
b) Add a constructor to the Person class developed above.

2. The employee list for a company contains employee code, name, designation
and basic pay. The employee is given HRA of 10% of the basic and DA of 45%
of the 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.
05 Lab 5 1. Write a program which defines base class Employee having three data
members, namely name[30], emp_numb and gender and two methods namely
input_data() and show_data(). Derive a class SalariedEmployee from Employee
and adds a new data member, namely salary. It also adds two member methods,
namely allowance (if gender is female HRA=0.1 *salary else 0.09* salary. DA=
0.05*salary) and increment (salary= salary+0.1*salary). Display the gross salary
in main class. (Tip: Use super to call base class’s constructor0).

2. WAP that illustrates method overriding. Class A3 is extended by Class B3.


Each of these classes defines a hello(string s) method that outputs the string “A3:
Hello From” or “B3: Hello From” respectively. Use the concept Dynamic
Method Dispatch and keyword super.
06 Lab 6 1. Write an abstract class shape, which defines abstract method area. Derive
class circle from shape. It has data member radius and implementation for area
function. Derive class Triangle from shape. It has data members height, base and
implementation for area function. Derive class Square from shape. It has data
member side and implementation for area function. In main class, use dynamic
method dispatch in order to call correct version of method.

2. Create an interface Shape2D which declares a getArea() method.. The


abstract class Shape declares abstract display () method .Circle class is
extended from shape class and implemented from shape2D interface. Write
appropriate method required in class circle and Create instance of circle object
and display area of circle
07 Lab 7 1. Create a package “employee” and define a Class Employee having three data
members, name, emp_num, and gender and two methods- input_data and
show_data. Inherit class SalariedEmployee from this class and keep it in
package “employee”. Add new variable salary and methods allowance (if female
hra=0.1* salary else 0.09* salary. DA= 0.05*salary) and increment (salary=
salary+0.01 * salary). Calculate gross salary in main class defined in the same
package.
08 Lab 8 1. WAP using try catch block. User should enter two command line arguments.
If only one argument is entered then exception should be caught. In case of two
command line arguments, if fist is divided by second and if second command
line argument is 0 then catch the appropriate exception.

2. Define an exception called “NoMatchException” that is thrown when a string


is not equal to “India”. Write a program that uses this exception.
09 Lab 9 1. The program to creates and run the following three threads. The first thread
prints the letter ‘a’ 100 times.
The second thread prints the letter ‘b’ 100 times.
The third thread prints the integer 1 to 100.

2. Write the thread program -1using Runnable interface.


10 Lab 10 1. Write a program that takes two files names (source and destination) as
command line argument .Copy source file’s content to destination file. Use
character stream class. Also do same using byte stream and buffer stream.

Write a program which generates random integers and stores them in a file
named “rand.dat”. The program then reads the integers from the file and displays
on the screen.
11 Lab 11 Write the program that demonstrate the use of Stack, Vector and ArrayList
classes
12 Lab 12 Write a Network program that client sends the data as redius of circle to server
and server received that data and send the resultant area of circle to requested
client.
13 Lab 13 Write a program to count occurrence of character in a string

Practicals Beyond syllabus


14 Lab 14 Write a programms to create simple calculator using applet

15 Lab 15 Write programms to create student registration form in applet and store data in
database.

You might also like