0% found this document useful (0 votes)
1 views1 page

Java Programs

The document outlines a series of Java programming exercises focused on creating classes, objects, and methods. It includes tasks for defining classes such as Student, Rectangle, Calculator, Circle, Employee, Book, BankAccount, Number, Exam, and LibraryBook, each with specific fields and methods. The exercises aim to enhance understanding of object-oriented programming concepts in Java.

Uploaded by

smanasa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

Java Programs

The document outlines a series of Java programming exercises focused on creating classes, objects, and methods. It includes tasks for defining classes such as Student, Rectangle, Calculator, Circle, Employee, Book, BankAccount, Number, Exam, and LibraryBook, each with specific fields and methods. The exercises aim to enhance understanding of object-oriented programming concepts in Java.

Uploaded by

smanasa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Java Programming Questions – Classes, Objects & Methods

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()

You might also like