Java Practical Program List
Java Practical Program List
1. Create a class Employee with members: empId, empName, and salary. Add a method
to calculate net salary after 10% tax. Create objects and display results.
2. Define a class Rectangle with methods to calculate area and perimeter. Use
constructors to initialize values and display using an object.
3. Create a menu-driven program using switch-case to perform arithmetic operations.
4. Accept marks of 5 subjects and calculate percentage, grade using if-else ladder.
5. Write a Java program to find whether a number is prime or not using a loop and logical
operators.
6. Write a Java program to demonstrate both (Implicit) and (Explicit) typecasting.
7. Write a Java program to input an array of integers and:
• Display all even numbers
• Find the maximum and minimum elements
8. Write a Java program with a class Person having name and age. Derive a class Student
with roll number and course. Display all details using inheritance.
9. Create three classes:
a. Employee → name, empId
b. Manager → department
c. ProjectManager → projectName
Display full details using multilevel inheritance.
10. Create a base class Vehicle with brand and speed. Derive Car and Bike classes from it,
and display details of both.
11. Create a class Animal with method sound(). In class Dog, override the method and
also call the parent class method using super.
12. Create an interface Printable with method print(). Create class Document that
implements this interface and prints a document name.
13. Create two interfaces:
a. Flyable with method fly()
b. Swimmable with method swim()
c. Implement both in a class Duck. Show how multiple inheritance works via
interfaces.
14. Write a Java program to perform division of two numbers. Handle ArithmeticException
if the denominator is zero.
15. Create a user-defined exception called InvalidAgeException. If a user enters age less
than 18, throw the exception with a message “Underage for Voting”.
16. Create a class that extends the Thread class and print numbers from 1 to 5 using a
thread.
17. Write a Java AWT Program by extending frame class.
18. Write a java AWT program by creating the object of Frame class.
19. Write a program implementing Menu & Menu bars.
20. Write a program implementing Event Listeners.
21. Write a program for simple swing application using swing components.
22. Write a program to connect java application with mysql database.
23. Write a program on TCP Client-Server in Java.
24. Write a program to display:
a. The local host name and IP address
b. The IP address of a domain like www.google.com
25. Create a Java application to insert 3 employee records and display them using a
SELECT query with Statement.