1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Yanka [14]
3 years ago
15

Design a class named Car that has the following fields:

Computers and Technology
1 answer:
snow_tiger [21]3 years ago
4 0

Answer:

// The class car is defined

public  class Car {

  // instance variable yearModel

  private int yearModel;

  // instance variable make

  private String make;

  // instance variable speed

  private int speed;

 

  // empty constructor

  // with instances inside it

  // the instances are from the question

  public Car(){

      yearModel = 2000;

      make = "Nissan";

      speed = 4;

  }  

  // overloaded constructor

  // constructor defined with three arguments

  public Car(int yearModel, String make, int speed) {

      // the arguments are assigned to the object's variable

      this.yearModel = yearModel;

      this.make = make;

      this.speed =speed;

  }

  // setter(mutator) method

  public void setYearModel(int yearModel){

      this.yearModel = yearModel;

  }

  // setter(mutator) method

  public void setMake(String make){

      this.make = make;

  }

  // setter(mutator) method

  public void setSpeed(int speed){

      this.speed = speed;

  }

  // getter(accessor) method

  public int getYearModel(){

      return yearModel;

   }

  // getter(accessor) method

  public String getMake(){

      return make;

   }

  // getter(accessor) method

  public int getSpeed(){

      return speed;

   }  

  // toString is override to display the car object properties

  public String toString(){

      return "Car's year model: " + getYearModel() + ", make: " + getMake() + ", speed: " + getSpeed();

  }

}

Explanation:

The code is well commented.

You might be interested in
What is the exact number of bytes in system of memory that contains (a) 64K bytes (In Binary)(b) 32M bytes
VashaNatasha [74]

Answer:

64 K bytes = 65536 bytes

32 M bytes = 33554432 bytes

Explanation:

The question expect the number of bytes in binary instead of decimal. So this is important to understand that:

  • 1K bytes = 1024 bytes (in binary)

Therefore,

  • 64 Kb = 64 x 1024 =  65536 bytes

Using the similar calculation logic, we know

  • 1M bytes = 1024 x 1024 = 1048576 bytes (in binary)

Therefore,

  • 32 M bytes = 32 x 1048576 =  33554432 bytes
5 0
3 years ago
In python, sorry if it’s blurry
stepan [7]

Answer:

nice

Explanation:

3 0
2 years ago
Read 2 more answers
Importance of software in computer
Juli2301 [7.4K]

Answer:

Computer hardware is virtually useless without computer software. Software is the programs that are needed to accomplish the input, processing, output, storage, and control activities of information systems.

Explanation:

4 0
3 years ago
Read 2 more answers
What is the index of 7 in this list?<br> [5, 6, 10, 7, 3, 2.51]
kotykmax [81]
5 or 7 I believe Good luck!
6 0
3 years ago
Read 2 more answers
What is the role of memory in a computer​
Anuta_ua [19.1K]

Answer:

Computer random access memory (RAM) is one of the most important components in determining your system's performance. RAM gives applications a place to store and access data on a short-term basis. It stores the information your computer is actively using so that it can be accessed quickly.

5 0
3 years ago
Other questions:
  • When inside a closed work environment, its okay to openly talk with co-workers about PII
    6·1 answer
  • Which answer best describes an unsubsidized federal loan
    9·1 answer
  • On Brainly, how can I change my username? from halfsidepancake​
    6·2 answers
  • Which of the following illustrates an example of a Boolean data type?
    15·1 answer
  • The Receiver recognizes the sounds the Sender is making and transforms them into words and ideas in his own mind. What is this
    5·1 answer
  • Write a program that uses nested loop or for statements to display Pattern A below, followed by an empty line and then another s
    5·1 answer
  • In computer science how can you define "copyright, designs and patents act 1988"?​
    8·1 answer
  • Match the definitions of different business communication to the type of document
    7·2 answers
  • Ill give alot of points if you answer: How do I get a 100 dollar ps4
    5·2 answers
  • Design a loop that asks the user to enter a number. The loop should iterate 10
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!