0% found this document useful (0 votes)
607 views

Java OOP Exercises

The document provides instructions for three object-oriented programming exercises in Java. The first set asks to create an Employee class with name, last name, and monthly salary instance variables, along with getter and setter methods and a test application to display yearly salaries. The second set asks to create a Book class with name, ISBN, author, and publisher instance variables, along with getter and setter methods and a getBookInfo method to return a description string. The third set is not described.

Uploaded by

Doode Moore
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
607 views

Java OOP Exercises

The document provides instructions for three object-oriented programming exercises in Java. The first set asks to create an Employee class with name, last name, and monthly salary instance variables, along with getter and setter methods and a test application to display yearly salaries. The second set asks to create a Book class with name, ISBN, author, and publisher instance variables, along with getter and setter methods and a getBookInfo method to return a description string. The third set is not described.

Uploaded by

Doode Moore
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Object-Oriented Programming Exercises(JAVA)

Set1.
Create a class called Employee that includes three pieces of information as
instance variables—a first name (type String), a last name (type String) and a
monthly salary (double). Your class should have a constructor that initializes the
three instance variables. Provide a set and a get method for each instance
variable. If the monthly salary is not positive, set it to 0.0. Write a test application
named EmployeeTest that demonstrates class Employee’s capabilities. Create
three Employee objects and display each object’s yearly salary.

Set 2.
Create a class called Book to represent a book. A Book should include four
pieces of information as instance variables‐a book name, an ISBN number,
an author name and a publisher. Your class should have a constructor
that initializes the four instance variables. Provide a mutator method and
accessor method (query method) for each instance variable. Inaddition,
provide a method named getBookInfo that returns the description of the
book as a String (the description should include all the information about
the book). You should use this keyword in member methods and
constructor. Write a test application named BookTest that demonstrates
the class Book's capabilities.

Set 3:

You might also like