Question

Write a JAVA program that declares a class Pet  With three variables Name, Age, weight .The class...

Write a JAVA program that declares a class Pet  With three variables Name, Age, weight .The class has  different constructors the first without parameters ,the  second with three parameters and the third with two parameters. In the main method  create three objects using thee different constructors to initialize the

Variables.  then print out all the information a bout all objects .

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The source code is compiled and the output is given below:

Add a comment
Know the answer?
Add Answer to:
Write a JAVA program that declares a class Pet  With three variables Name, Age, weight .The class...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Anyone helps me in a Java Languageif it it is possible thanks. Write a class called...

    Anyone helps me in a Java Languageif it it is possible thanks. Write a class called Player that holds the following information: Team Name (e.g., Ravens) . Player Name (e.g., Flacco) . Position's Name (e.g. Wide reciver) . Playing hours per week (e.g. 30 hours per week). Payment Rate (e.g., 46 per hour) . Number of Players in the Team (e.g. 80 players) . This information represents the class member variables. Declare all variables of Payer class as private except...

  • (JAVA) Use the Pet.java program from the original problem (down below) Compile it. Create a text...

    (JAVA) Use the Pet.java program from the original problem (down below) Compile it. Create a text file named pets10.txt with 10 pets (or use the one below). Store this file in the same folder as your “class” file(s). The format is the same format used in the original homework problem. Each line in the file should contain a pet name (String), a comma, a pet’s age (int) in years, another comma, and a pet’s weight (double) in pounds. Perform the...

  • Write a Java class (name it TwoNumbers) that will manage two numbers. The class should have...

    Write a Java class (name it TwoNumbers) that will manage two numbers. The class should have two integer variables. The class should have the following constructors: - TwoNumbers(); - TwoNumbers(3, 4); The first constructor should initialize the class variables to zero. The second constructor should initialize the class variables to the passed variables. The class should have the following methods: - setNumbers(3, 4); - setFirstNum(3); - setSecondNum(4); - getSum(); - getDiff(); - getProd(); The setNumbers(3, 4) method should initialize the...

  • Write a complete Java program to create three types of counters as follows: The first counter...

    Write a complete Java program to create three types of counters as follows: The first counter increases its value by one. The second counter increases its value by two. The third counter increases its value by three. Please follow these notes: Create one class for all counter types. The name of the class is Three_type_counter. Define a constructor method that initial values for all counters to 7 when the class object created. Create method for each counter as: count1, count2...

  • Write a program

    1. Write a program which have a class named as “Student”, while the data members of the class are,a. char name[10],b. int age;c. string color;d. string gender;e. double cgpa;and the member function “print()”,  is just to display these information.1. You need to create 3 objects of the “Student” class.2. Initialize one object by the default constructor having some static values.3. Initialize the second object by the parameterized constructor, while you need to pass values for initialization.4. Initialize the third object...

  • This assignment shpuld be code in java. Thanks Overview In this assignment you will write a...

    This assignment shpuld be code in java. Thanks Overview In this assignment you will write a program that will model a pet store. The program will have a Pet class to model individual pets and the Assignment5 class will contain the main and act as the pet store. Users will be able to view the pets, make them age a year at a time, add a new pet, and adopt any of the pets. Note: From this point on, your...

  • JAVA QUESTION 16 Write and submit the java source for the following class specification: The name...

    JAVA QUESTION 16 Write and submit the java source for the following class specification: The name of the class is Question_16 Class Question_16 has 3 instance variables: name of type String, age of type int and height of type double. Class Question_16 has the following methods: print - outputs the data values stored in the instance variables with the appropriate label setName - method to set the name setAge - method to set the age setHeight - method to set...

  • Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and...

    Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and name variables (do not include topTrick). Note: The type refers to what the breed typically does; for example, a corgi would be a “cattle herding dog.” A Shiba Inu would be a “hunting dog.” Create the setTopTrick() mutator method Dog is parent class Corgi and Driver are subclasses Complete the Corgi class: Using the UML Class diagram, declare the instance variables. Create the two...

  • How to write a program that create a car class with: instance variables name and mpg...

    How to write a program that create a car class with: instance variables name and mpg (make public) No need for a main() method In a separate file, create a CompareCars class with a main()method create 2 instances of car using new set the name and mpg for each instance variables are public, so use the name an mpg to access the instance variables compare the fuel efficiency of your 2 cars and print out which is more efficient to...

  • Write a program in C++ with comments! Create an abstract class Property, containing the data items...

    Write a program in C++ with comments! Create an abstract class Property, containing the data items owner, address and price. Add an abstract method showOwner(). Also provide getter/setters for all the data items. Make validations if necessary in the setter so that no invalid values are entered. Create a class House, to inherit the Property class. This class should contain additional data item – yardSize – an integer – the size of the yard of the house, getter and setter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT