Java Programs
Java Programs
1. Create a class `Student` with fields name, rollNo, and marks. Write a method to display
student details.
2. Create a class `Rectangle` with length and breadth. Write methods to:
- Set values
- Calculate area
- Calculate perimeter
3. Create a class `Calculator` with methods for:
- Addition
- Subtraction
- Multiplication
- Division
4. Write a program to create a `Circle` class. Include method to calculate and return area.
5. Create a class `Employee` with fields name, empId, salary. Write a method to display
details and another method to check if salary is above 50,000.
6. Create a class `Book` with fields: title, author, and price. Use constructor to initialize
values. Write method to display info.
7. Create a class `BankAccount` with:
- Fields: accountNumber, name, balance
- Methods: deposit(), withdraw(), displayBalance()
8. Create a class `Number` with two integer variables. Write a method to swap two
numbers using object as parameter.
9. Create a class `Student` and another class `Exam`. Pass student object to exam class and
print the result.
10. Create a class `LibraryBook` with:
- Fields: bookId, name, author
- Methods: setDetails(), showDetails()