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
Nata [24]
2 years ago
5

An address has a house number, a street, an optional apartment number, a city, a state and a postal code. Define the constructor

such that an object can be created in one of two ways: with an apartment number or without. Supply a print method that prints the address with the street on one line and the city, state and postal code on the next line.
Computers and Technology
1 answer:
Sveta_85 [38]2 years ago
5 0

Answer:

public class Address {

   private int houseNumber;

   private String street;

   private int apartmentNumber;

   private String city;

   private String state;

   private String postalCode;

   //First Constructor with an Apartment Number

   public Address(int houseNumber, String street, int apartmentNumber, String city, String state, String postalCode) {

       this.houseNumber = houseNumber;

       this.street = street;

       this.apartmentNumber = apartmentNumber;

       this.city = city;

       this.state = state;

       this.postalCode = postalCode;

   }

   // Second Constructor Without Apartment Number

   public Address(int houseNumber, String street, String city, String state, String postalCode) {

       this.houseNumber = houseNumber;

       this.street = street;

       this.city = city;

       this.state = state;

       this.postalCode = postalCode;

   }

   // Creating Getter Methods

   public int getHouseNumber() {

       return houseNumber;

   }

   public String getStreet() {

       return street;

   }

   public int getApartmentNumber() {

       return apartmentNumber;

   }

   public String getCity() {

       return city;

   }

   public String getState() {

       return state;

   }

   public String getPostalCode() {

       return postalCode;

   }

   //A Print Method to print an Address

   public void printAddress(){

       System.out.println(getStreet()+" Street"); //First line of the address

       System.out.println(getCity()+", "+getState()+" State, "+getPostalCode());//Second line of the address

   }

}

Explanation:

In Java, A class is created called Address

The house number, street, apartment number, city, state and postal code are all created as the class member variables (fields)

Two constructors are created. The first initializes all the fields so an object of the class contains all the fields. The second does not initialize the optional apartment number. This technique is called constructor overloading

Getter methods are created for all the fields

A method printAddress() is created that prints as stipulated by the question. Do pay attention to the comments in the code

You might be interested in
Banks use _____, which are electronic transmissions of account exchange information over private communications’ networks.
faltersainse [42]

Answer:

Wire transfer

Explanation:

Wire Transfer also known as remittance under the U.S. law is the electronic transfer of money which is carried out across a network that is run by several banks and money transfer agencies around the globe. With Wire Transfer, people at different parts of the Word can securely send money to individuals at other financial institution in any part of the world.

The following are important points to note about wire transfers:

1. It is an electronic transfer of funds across a network of banks and money transfer agencies around the world.

2. The individual or senders pays a transaction fee at their banks and must provide the receivers details including bank name and account number.

3. Wire transfers can take up to two working days to complete

4. The Office of Foreign Assets monitors and controls international wire payments, to prevent money laudering and funding of illegal activities like terrorism

7 0
2 years ago
If i don't update my computer what threat does my computer face?
Nadusha1986 [10]
Hey there! Hello!

Computer updates, especially smaller security updates, contain security information for new bugs, malware, viruses, etc. that have been written since your last update. So many of these are written for computers at any given time, meaning that keeping your computer updated is a significant step in keeping your computer's defense systems working. Paired up with legit anti-malware, virus protection software, good computer knowledge, and common sense, your computer can remain very safe from these viruses. 

Otherwise, there might be some bug or irregularity within your computer's system itself that was accidentally released an update or two ago by the creators of your computer's software, which may also pose a threat for your computer system. Updating your computer can most likely fix problems like these. But, more commonly, they just keep your computer up to date on the vicious computer threats that are now available for it since the previous update. 

Hope this helped you out! Feel free to ask me any additional questions if you have any. :-)

8 0
3 years ago
are the network administrator for your company. You are installing a new printer in the network. When you check the print server
melamori03 [73]

Answer:

Will have to run the net start spooler command.

Explanation:

  • The printer spooler seems to be accountable for overseeing incoming faxes that have been in effect intended for handling by the printer. Whether this device stops operating, your printer won't publish documentation as well as the machine may not notice it either.
  • To solve these problems, you'll need to run the net start spooler command using the least administrative effort.
5 0
2 years ago
I WILL MARK THE BRAINIEST!!!!!!!!!!!!! 50 POINTS!!!!!!!
Sauron [17]
Hello,

Your answer would be:

1. It’s important to have a good study skill so you can be ready to take a quiz such as world history.

2. It’s important to know your time on tasks because you don’t want to spend all day on one simple task you want to get things done.

3. A schedule can help you get organzied because it helps you with your time such as this go along with your second question.

Have a nice day :)

~Rendorforestmusic
5 0
3 years ago
Read 2 more answers
The primary reason for the creation of the Federal Reserve System LOADING... ​was: A. to create a single central bank similar to
Gelneren [198K]

Answer: (C) to reduce or eliminate future bank panics.

Explanation:

The Federal Reserve System being the central reserve system in the US was created with the primary objective of reducing and eliminating bank panics in periods of recessions and depressions and other bank related matters.

3 0
3 years ago
Other questions:
  • What two images did you have to add to the wds server to handle the windows installation?
    7·1 answer
  • Consider a method defined with the header:
    13·1 answer
  • The ________ option contains the formatting and placeholders for all of the items that appear on a side.
    11·1 answer
  • When looking at a relationship between two tables on an ERD, the _____ table can be identified by the presence of a foreign key
    8·1 answer
  • Which of the following comments are correct? Select all that apply.
    14·1 answer
  • What will you see on the next line?
    6·2 answers
  • What does input allow a computer to do
    14·1 answer
  • 1. Write a statement that opens the file Customers.dat as a random access file for both reading and writing.
    9·1 answer
  • China's cultural diversity, China is composed of 56 ethnic groups.
    5·1 answer
  • Binary subtraction<br> Subtract (111) from (1000)
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!