Question: Java program , task1, 2,and 3 Task 1: Creating a class with default constructor Create a class called DeliveryTruckGpsSensor that has the following

Java program , task1, 2,and 3
Java program , task1, 2,and 3 Task 1: Creating a class with

Task 1: Creating a class with default constructor Create a class called " DeliveryTruckGpsSensor " that has the following attributes: currentLatitude, currentLongitude, destinationLatitude and destinationLongitude. a) Create a new class file named "DeliveryTruckGpsSensor." b) Create a default constructor. c) Create another class named "Test" containing the main() method d) Inside the main() method create at least two objects e) Assign values for the data members in the new created object using the dot operator. f) Print out the values for the data members for each object created Task 2: Creating parameterized constructor. Using the previous Class, add a parameterized constructor to initialize the data fields. a) add another constructor with four parameters. b) Modify the created objects in the Test class by assigning values to the data members when you are creating the object. c) Print out the values for the data members for each object created. Task 3: Data field encapsulation Modify the previous class and make its data members private, add the static variable called "numberofobjcets" to count the number objects created, add setters and getters for each data filed. In addition, add the toString method a) In the Test Program, create at least two objects and call the setters to access and modify the data fields. b) Get the number of objects created by calling the static function getNumberofobjects() c) Call the tostring method for each object. d) What is the purpose of adding setters and getters

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!