Question: in Java: 1. Create a class named after your favorite object in the whole world. For example, if you love pizza, then create a class
in Java:
1. Create a class named after your favorite object in the whole world. For example, if you love pizza, then create a class called Pizza.java. This class should not have a main method
2. Create Instance Variables (attributes) (1 point)
Create at least 3 private instance fields (attributes) for your class
You must use at least 3 different data types for your fields
3. Create getter (accessor) and setter (mutator) methods
Create a getter (accessor) method for each of your instance variables (1 point)
Create a setter (mutator) method for each of your instance variables (1 point)
4. Create a Method to display your data (1 point)
Create a method called display, that simply prints out the values of all instance variables of your object
5. Create 2 Constructors
Create a default constructor (no parameters) that assigns all your instance variables to default values (1 point)
Create a parameterized constructor that takes all instance variables as parameters, and sets the instance variables to the values provided by the parameters (1 point)
6. Testing your program (1 point)
Create a class called Demo.java. This class will contain your main method
Create an instance of your class by using the default constructor.
Call all your objects set methods to assign values to your object
Call the objects display method, to print out it's values
Create another instance of your class by using the parameterized constructor
Call the objects display method, to print out it's values
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
