CLASS and OBJECT JAVA ASSIGNMENT
1. Write a Java program to create a Student class with attributes roll number,
name, and marks, and display student details using an object.
2. Write a Java program to create an Employee class with attributes employee
ID, name, and salary, and display employee details using an object.
3. Write a Java program to create a Book class with attributes book ID, title,
and price, and display book details using an object.
4. Write a Java program to create a Car class with attributes model name, color,
and price, and display car details using an object.
5. Write a Java program to create a Bike class with attributes brand name,
model, and mileage, and display bike details using an object.
6. Write a Java program to create a Mobile class with attributes brand, model,
and price, and display mobile details using an object.
7. Write a Java program to create a Laptop class with attributes company name,
processor, and RAM, and display laptop details using an object.
8. Write a Java program to create a Rectangle class with attributes length and
width, and calculate the area using an object.
9. Write a Java program to create a Circle class with attributes radius, and
calculate the area and circumference using an object.
10. Write a Java program to create a Square class with attributes side, and
calculate the area and perimeter using an object.
11. Write a Java program to create a Triangle class with attributes base and
height, and calculate the area using an object.
12. Write a Java program to create a BankAccount class with attributes account
number, account holder name, and balance, and display account details
using an object.
13. Write a Java program to create a SimpleInterest class with attributes principal,
rate, and time, and calculate simple interest using an object.
14. Write a Java program to create an ElectricityBill class with attributes customer
name, units consumed, and rate per unit, and calculate the bill using an
object.
GADEKAR M.J. 1
15. Write a Java program to create a Salary class with attributes employee name,
basic salary, and allowance, and calculate total salary using an object.
16. Write a Java program to create a Temperature class with attributes Celsius
temperature, and convert it into Fahrenheit using an object.
17. Write a Java program to create a Distance class with attributes kilometers,
and convert it into meters using an object.
18. Write a Java program to create a Time class with attributes hours and
minutes, and convert time into total minutes using an object.
19. Write a Java program to create a Marks class with attributes student name,
subject marks, and total marks, and calculate percentage using an object.
20. Write a Java program to create a Result class with attributes student name,
marks, and grade, and display the result using an object.
21. Write a Java program to create a Number class with an attribute number, and
check whether it is even or odd using an object.
22. Write a Java program to create a Number class with attributes number1 and
number2, and find the largest number using an object.
23. Write a Java program to create a Number class with attributes number1,
number2, and number3, and find the largest number using an object.
24. Write a Java program to create a Swap class with attributes first number and
second number, and swap the values using an object.
25. Write a Java program to create a Factorial class with attribute number, and
calculate factorial using an object.
26. Write a Java program to create a Prime class with attribute number, and
check whether the number is prime using an object.
27. Write a Java program to create a Palindrome class with attribute number, and
check whether it is a palindrome using an object.
28. Write a Java program to create an Armstrong class with attribute number, and
check whether it is an Armstrong number using an object.
29. Write a Java program to create a Fibonacci class with attribute limit, and
generate Fibonacci series using an object.
30. Write a Java program to create a ReverseNumber class with attribute number,
and reverse the number using an object.
GADEKAR M.J. 2
31. Write a Java program to create a DigitSum class with attribute number, and
calculate the sum of digits using an object.
32. Write a Java program to create a Product class with attributes product ID,
product name, and price, and display product details using an object.
33. Write a Java program to create a Customer class with attributes customer ID,
name, and mobile number, and display customer details using an object.
34. Write a Java program to create a Patient class with attributes patient ID,
name, and disease, and display patient details using an object.
35. Write a Java program to create a Doctor class with attributes doctor ID,
name, and specialization, and display doctor details using an object.
36. Write a Java program to create a School class with attributes school name,
address, and principal name, and display school details using an object.
37. Write a Java program to create a College class with attributes college name,
course, and location, and display college details using an object.
38. Write a Java program to create a Library class with attributes book name,
author name, and issue date, and display library details using an object.
39. Write a Java program to create a Hotel class with attributes hotel name, room
number, and room charge, and display booking details using an object.
40. Write a Java program to create a BusTicket class with attributes passenger
name, bus number, and ticket price, and display ticket details using an
object.
41. Write a Java program to create a TrainReservation class with attributes
passenger name, train number, and seat number, and display reservation
details using an object.
42. Write a Java program to create a MovieTicket class with attributes movie
name, seat number, and ticket price, and display ticket details using an
object.
43. Write a Java program to create a CricketPlayer class with attributes player
name, age, and runs, and display player details using an object.
44. Write a Java program to create a FootballPlayer class with attributes player
name, age, and goals, and display player details using an object.
45. Write a Java program to create an Exam class with attributes student name,
exam name, and marks, and display exam details using an object.
GADEKAR M.J. 3
46. Write a Java program to create a Voter class with attributes voter name, age,
and voter ID, and check voting eligibility using an object.
47. Write a Java program to create a CurrencyConverter class with attributes
amount and conversion rate, and convert currency using an object.
48. Write a Java program to create a BMI class with attributes weight and
height, and calculate BMI using an object.
49. Write a Java program to create an AgeCalculator class with attributes birth
year and current year, and calculate age using an object.
50. Write a Java program to create a Calculator class with attributes number1 and
number2, and perform arithmetic operations using an object.
GADEKAR M.J. 4