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]
3 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]3 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
Can development and conservation of environment go hand-in-hand? Explain your point of view
Wewaii [24]

No, development and conservation of environment cannot hand in hand.

Explanation:

Because during the developmental process the destruction of the environment is necessary.For example,if you want to construct a Road which is one of the developmental activity,so to construct road the clear of forest is must .

5 0
3 years ago
What is required for real-time surveillance of a suspects computer activity?/p Group of answer choices a. Blocking data transmis
Hitman42 [59]

Answer:

c  Preventing data transmissions between a suspect’s computer and a network server

Explanation:

3 0
3 years ago
Which is not an example of a boolean operator?
allochka39001 [22]
1. Because is not an example of and Boolean operator

2. Google is the internets top search engine

I hope this helped
3 0
4 years ago
Read 2 more answers
If your database is in archivelog mode, how can you force an archive?
MA_775_DIABLO [31]

Answer: (B) Issue an alter system switch logfile command.

Explanation:

 When the database is in the archive log mode then, the issue in the alter system switch logfile command force the particular switch. It basically produce achieve redo log which is smaller in the size by the dedicated size of the parameter log buffer.

It also govern the particular size of the RAM (Random access memory) buffer by redo log.  This command is basically faster to return in the program by the use of redo log.

On the other hand, all the options are incorrect as this command only alter the system and does not alter the database. Therefore, Option (B) is correct.

 

8 0
3 years ago
How can you solve real world mathematical problems using two linear equations in two variables​
ipn [44]

Answer:

import numpy as np

a = int(input ("Enter a"))

b = int(input ("Enter b"))

c = int(input ("Enter c"))

d = int(input ("Enter d"))

c1 = int(input ("Enter c1"))

c2 = int(input ("Enter c2"))

array1 =[[a, b],[c, d]]

A = np.array (array1)

B = np.array ([c1, c2])

X = np.linalg.inv (A).dot (B)

print (X)

Explanation:

let ax + by =c1

     cx + dy =c2

We have used the above NumPy library that has the methods for matrix calculation, and here we have used matrix multiplication, and the inverse of a matrix to find the value of x and y.

We know AX=B

X = inv A. B

And this we have used above. We can calculate inv A and do matrix multiplication using NumPy. And thus we get the above solution.

3 0
3 years ago
Other questions:
  • Which of the selections below is not a benefit of imaging the computers on your network? There are fewer licensing fees because
    11·1 answer
  • Which of the following would an interactive media professional most likely need? A.a high school diploma
    15·1 answer
  • so i just went to play forge of empires and when i logged on to it all of my progress was gone and i was so far in to it
    15·2 answers
  • Which of the following is one of the first steps in implementing a comprehensive security program? Setting up a Guest account Cr
    14·1 answer
  • Software that requires excessive disk space or memory.
    15·1 answer
  • The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and eac
    12·1 answer
  • Given the following statement, what is the value of myExample?
    13·1 answer
  • The Internet is a worldwide communications network. Which device connects computer networks and computer facilities?
    11·1 answer
  • How dose computers it use the information to solve problems
    6·1 answer
  • Give a common business example that mimics the differences between a shared
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!