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
Ganezh [65]
3 years ago
10

Consider the partially-filled array named a. What does the following loop do? (cin is a Scanner object)int[] a = {1, 3, 7, 0, 0,

0};int size = 3, capacity = 6;int value = cin.nextInt();while (value > 0){a[size] = value;size++;value = cin.nextInt();}1. May crashe at runtime because it can input more elements than the array can hold2. Reads up to 3 values and inserts them in the array in the correct position.3. Reads one value and places it in the remaining first unused space endlessly.4. Reads up to 3 values and places them in the array in the unused space.
Computers and Technology
1 answer:
boyakko [2]3 years ago
8 0

Answer:

Option 1: May crash at runtime because it can input more elements than the array can hold

Explanation:

Given the code as follows:

  1.        int[] a = {1, 3, 7, 0, 0, 0};
  2.        int size = 3, capacity = 6;
  3.        int value = cin.nextInt();
  4.        while (value > 0)
  5.        {
  6.            a[size] = value;
  7.            size++;
  8.            value = cin.nextInt();
  9.        }

From the code above, we know the <em>a</em> is an array with six elements (Line 1). Since the array has been initialized with six elements, the capacity of the array cannot be altered in later stage.

However, a while loop is created to keep prompting for user input an integer and overwrite the value in the array started from index 3 (Line 4- 9). In every round of loop, the index is incremented by 1 (Line 7). If the user input for variable <em>value</em> is always above zero, the while loop will persist.  This may reach a point where the index value is out of bound and crash the program. Please note the maximum index value for the array is supposedly be 5.  

You might be interested in
Which descriptions offer examples of Correction Services workers? Select all that apply.
lutik1710 [3]

B.) Doug supervises Jailers and makes sure their work meets standards.

E.) Rudy monitors people who are on probation and parole.

F.) Nancy guards inmates in a prison.

4 0
3 years ago
In what scenario should dhcp servers also be active dhcp clients?
mrs_skeptik [129]
DHCP stands for Dynamic Host Configuration Protocol. It is protocol responsible for c<span>onfiguring the IP address and other TCP/IP settings on network computers. </span>There is no scenario in which DHCP servers also be active DHCP clients. They should never be both a DHCP server and DHCP client. The two sides (client and server) should be always separated.
4 0
3 years ago
you just bought a new hard drive for your computer to be used as a secondary hard drive to store all your files after installing
almond37 [142]
The harddrive needs to be partitioned, much like partitioning a room, this is were you allocate space to be used, and used by who. Secondly, a file system needs to installed, to do this you "format" the drive with one of the available File systems that windows can read. Typically on windows this is NTFS or fat32 for older system or devices such as USB sticks.  
6 0
4 years ago
What are two examples of items in Outlook?
marta [7]

Answer:

I believe it would be button and tool bar

8 0
3 years ago
How are charts useful in Excel worksheets? Name three types of charts available in Excel and describe with an example how each m
kap26 [50]

Answer:

Spread sheets

Explanation:

8 0
2 years ago
Other questions:
  • You receive an offer for a credit card that can be use to accrue points that
    11·1 answer
  • What did you include in your response? Check all that
    15·1 answer
  • Create a website for an online movie rental store, using HTML (and any other client technologies) and PHP. The website should in
    8·1 answer
  • Does the cloud solution offer equal or greater data security capabilities than those pro-vided by your organization’s data cente
    14·1 answer
  • (08.03 MC) Maya is a senior in high school and would like to pursue a career in web design. She needs more information about wha
    11·2 answers
  • What will be the result of running the following code fragment? int year = 0; double rate = 5; double principal = 10000; double
    14·1 answer
  • How does a author develop a character in a story?
    14·2 answers
  • Files exist on ____ storage devices, such as hard disks, dvds, usb drives, and reels of magnetic tape.
    11·1 answer
  • What number system is the basis for all of the powerful computers and electronic devices in the world?
    7·1 answer
  • The science of networking is attributed to which government's involvement?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!