Define a constructor as indicated. sample output for below program:

Posted By Admin @ September 03, 2022


Define a constructor as indicated. Sample output for below program:Year: 0, VIN: -1Year: 2009, VIN: 444555666// ===== Code from file =====public class CarRecord {private int yearMade;private int vehicleIdNum;public void setYearMade(int originalYear) {yearMade = originalYear;return;}public void setVehicleIdNum(int vehIdNum) {vehicleIdNum = vehIdNum;return;}public void print() {System.out.println("Year: " + yearMade + ", VIN: " + vehicleIdNum);return;}// FIXME: Write constructor, initialize year to 0, vehicle ID num to -1./* Your solution goes here */}// ===== end ===== //===== Code from file =====public class CallCarRecord {public static void main (String args) {CarRecord familyCar = new CarRecord();familyCar.print();familyCar.setYearMade(2009);familyCar.setVehicleIdNum(444555666);familyCar.print();return;}}// ===== end =====


A constructor is a block of code that is called and executed each time an object is created.

The constructor in Java is as follows:

public CarRecord(){

       yearMade = 0;

       vehicleIdNum = -1;


A constructor would have the same name as the class.

The class of the program is CarRecord; so the constructor name is CarRecord()

From the question, variables year and vehicles ID are to be initialized to 0 and  -1 respectively.

So, the variable initialization is:

       yearMade = 0;

       vehicleIdNum = -1;

Hence, the complete code segment is:

public CarRecord(){

       yearMade = 0;        vehicleIdNum = -1;


Read more about constructors at:

Similar Questions

  1. Define a constructor as indicated. sample output for below program
  2. Once business strategy is defined for an artificial intelligence program
  3. Indicate the point where a monopoly will set its output.
  4. What defines the behavior of an object in object-oriented programming
  5. Complete and balance the following redox reaction in basic solution
  6. Enzymes affect the reaction in living cells by changing the
  7. Which are uses of electromagnetic waves check all that apply
  8. The main source of energy that drives global climate is:
  9. What is the basic difference between exergonic and endergonic reactions
  10. Approximately what percentage of the water on earth is freshwater
  11. Which lobes of the brain receive input from the nose
  12. How many foci does the graph of a hyperbola have
  13. Find an equation for the conic whose graph is shown.
  14. How are organisms in the domains bacteria and archaea similar
  15. What is the basic principle of the law of demand
  16. A debit is used to record which of the following:
  17. What is the solution to the system of equations brainly
  18. Our store management seems to be in constant flux meaning
  19. Which of the following statements about vocabulary building is correct
  20. Which group depended on the trade network for raw materials
  21. Kim leads a team of graduate students in food science
  22. What is the sum of 15 and its additive inverse
  23. The definition of a circle uses the undefined term _______.
  24. Explain the significance of the last line in the novel
  25. A sentence containing an intransitive verb has an indirect object
  26. At which body of water does the nile river end
  27. What is one of the key features of blank verse
  28. Cranes and associated rigging equipment must be inspected how often
  29. Initiation elongation and termination are the three main steps in
  30. What is the role of enzymes in dna replication process
  31. A car is stopped at a traffic light ap physics
  32. Why did california's application for statehood cause a sectional crisis
  33. Which factor is most likely to contribute to tobacco use
  34. What major cities are located by the san andreas fault
  35. What is the percent of change from 5 to 7
  36. Which of these groups of particles has the greatest mass
  37. Scientists hypothesize that there are no dinosaurs alive today because
  38. Which arrow represents the activation energy of the forward reaction
  39. Is a neurotransmitter with roles in pleasure and pain modulation
  40. What do plant animal and bacteria cells have in common
  41. What was the main goal of american business in cuba
  42. A desktop computer is to be cooled by a fan
  43. What is the significance of the mcculloch v maryland case
  44. Where within the cell is the majority of atp produced
  45. Name the subunits that make up each of the macromolecules
  46. Describe the relative densities of the phases for most substances
  47. Which is true about the development of farming in sumer
  48. What is the z score for a 99 confidence interval
  49. To be thus is nothing but to be safely thus
  50. Who is widely considered to be the father of genetics
  51. Area of sociology devoted to the study of human populations
  52. What was the long-term effect of the bleeding kansas problem
  53. Which layer of the atmosphere contains the most water vapor
  54. Which eoc configuration allows personnel to function in the eoc
  55. Assuming a purely inductive circuit current will the voltage by
  56. What was one result of the federal employee loyalty program
  57. A company is performing an analysis on the computer leetcode
  58. Graph the equation using the slope and the y intercept
  59. Which statement about water best illustrates the property of adhesion
  60. The answer to life the universe and everything easter egg
  61. A company starts to track the number of phone calls
  62. The first permanent english settlement in the new world was
  63. A tragedy of the commons occurs when a resource is
  64. All of the following are characteristics of metamorphic rocks except
  65. A good man is hard to find commonlit answer key
  66. How is thomas jefferson related to the war of 1812
  67. Which phrase best describes a period on the periodic table
  68. What was the goal of the lewis and clark expedition
  69. When reading a play the reader has to imagine the
  70. How does an f+ cell differ from an hfr cell
  71. 1 2 4 8 16 32 64 128 256 512
  72. A cell that protects the body by eating invading cells
  73. Why does a lawn mower live such a hard life
  74. A type of trilobite is used as an index fossil
  75. How many almonds does it take to make a gallon

What is one component in photosynthesis that is not recycled

The one component in photosynthesis that can't be recycled but must be constantly available is energy.Light energy, mostly from sunlight, is the main requirement for …

According to most state laws a hospital pharmacy technician can

The study of drugs is called medicine. There are two types of drugs and these are psychotropic and psychedelic.The correct answer to the question is …

Which of the following best describes term life insurance brainly

The right answer for the question that is being asked and shown above is that: "b. The insured pays a premium for a specified number …

How much does a gallon of milk weigh in pounds

12.2 gallons of milk weigh 104.981 pounds.You get this by simply multiplying the weight of 1 gallon of milk to the 12.2 gallons of milk. …

How to know if a graph is even or odd

Answer:evenStep-by-step explanation:An even function is symmetrical about the y- axis.The graph of the function given is symmetrical about the t- axis and is therefore even.

Which function is positive for the entire interval 3 2

Answer:Graph BStep-by-step explanation:We are given 4 graphs.We need to find the function graph which is positive of the entire interval [-3, -2]It is a closed …

How does the tilt of the earth affect the seasons

Because the earth's axis is tilted, one hemisphere is closer to the sun than the other in certain times of the year. In the Northern …

In an enzyme-controlled reaction a substrate is the same as

In an enzyme controlled reaction, a substrate is the same as a reactant.Reactant is a substance that will be used (there will be reduced) in …

Total amount of living tissue within a given trophic level

Answer is D- biomassBiomass indicates that how does the energy flow within tropic levels. It is the amount of energy that a tropic level has …

How does a bacteria's resistance to an antibiotic first arise

Answer:1. B. through mutation 2. B develop and use new antibiotics 3. C. make pesticides more toxic Explanation:your welcome :)

Adalyn wants to find a job in education and training

Answer:A. curriculum developerExplanation:A curriculum developer refers to an individual who is typically an educational professional who is saddled with the responsibility of creating or developing …

Local environmental changes have no effect on the global climate

The statement above is rather false. Local environment changes do have an effect on the global climate. Scientists believe that because of this and the …

How do you redeem a winning lottery ticket walmart quizlet

One can redeem the winning ticket by:validating the ticket on lottery terminalscan ticket on posuse lottery winning ticket redemptionWhat is a winning lottery ticket?These are …

All of the following are good sources of protein except

Answer: D. PastaExplanation: Fish, eggs and nuts have protein, so I used process of elimination. ^-^

Organic molecule that speeds up chemical reactions without being consumed

Answer:(1)Catalyst, (2) substrate, (3) active site, (4)activation energy, (5)induced fit, (6)cofactor, (7)denatureExplanation:An example of an enzyme is carbonic anhydrase. It catalyzes the reversible reaction between …