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
Nadya [2.5K]
3 years ago
15

Consider the following code segment: ArrayList bulbs = new ArrayList(); bulbs.add(new Light()); bulbs.remove(0); bulbs.add(new L

ight()); Light b = new Light(); bulbs.add(1, b); bulbs.add(new Light()); bulbs.remove(0); bulbs.add(new Light()); bulbs.remove(2); bulbs.add(new Light()); bulbs.add(1, new Light()); After running the code, what is the size of bulbs?
Computers and Technology
2 answers:
mezya [45]3 years ago
6 0

Answer:

4

Explanation:

ArrayList bulbs = new ArrayList();

bulbs.add(new Light()); // bulbs array length equal to 1

bulbs.remove(0); // bulbs array length equal to 0

bulbs.add(new Light()); // bulbs array length equal to 1

Light b = new Light();

bulbs.add(1, b); // bulbs array length equal to 2

bulbs.add(new Light()); // bulbs array length equal to 3

bulbs.remove(0); // bulbs array length equal to 2

bulbs.add(new Light()); // bulbs array length equal to 3

bulbs.remove(2); // bulbs array length equal to 2

bulbs.add(new Light()); // bulbs array length equal to 3

bulbs.add(1, new Light()); // bulbs array length equal to 4

Scrat [10]3 years ago
4 0
To answer this, lets run through the code:

<span>ArrayList bulbs = new ArrayList(); //create a new empty list

bulbs.add(new Light()); //size of bulbs  = 1

bulbs.remove(0); //remove item at index 0. size of bulbs = 0

bulbs.add(new Light()); // size of bulbs = 1

Light b = new Light();
bulbs.add(1, b); // size of bulbs = 2

bulbs.add(new Light()); //size of bulbs = 3

bulbs.remove(0); //remove bulb at index 0. Size of bulbs = 2

bulbs.add(new Light()); size of bulbs = 3

bulbs.remove(2); //remove bulb at index 2. size of bulbs = 2

bulbs.add(new Light()); //size of bulbs = 3

bulbs.add(1, new Light()); //inserted at position 1. size of bulbs = 4

The final answer. Size of bulbs = 4.</span>
You might be interested in
PLS CAN ANYONE HELP ME
Nesterboy [21]

The exercise contains 15 questions. The solution is provided for each question.

Each question contains the necessary skills you need to learn.

I have added tips and required learning resources for each question, which helps you solve the exercise. When you complete each question, you get more familiar with a control structure, loops, string, and list.

Use Online Code Editor to solve exercise questions.

Also, try to solve the basic Python Quiz for beginners

Exercise 1: Given two integer numbers return their product. If the product is greater than 1000, then return their sum

Reference article for help:

Accept user input in Python

Calculate an Average in Python

Given 1:

number1 = 20

number2 = 30

Expected Output:

The result is 600

Given 2:

number1 = 40

number2 = 30

Expected Output:

The result is 70

Explanation:

4 0
3 years ago
20 points
riadik2000 [5.3K]
By the year 2030, artificial intelligence (A.I.) will have changed the way we travel to work and to parties, how we take care of our health and how our kids are educated.
3 0
4 years ago
Read 2 more answers
Relieved to have survived ,henry rolled off the rink________.giving alex a grateful look
Marina86 [1]

Answer:

simultaneously might be the answer

8 0
3 years ago
What is the output of
Vaselesa [24]
0
1
2
3
4

Those are the outputs
6 0
3 years ago
Read 2 more answers
when you enter a formula in a cell the result of the calculation displays in a cell. how do views of formula after entering it?
Vika [28.1K]

<u>Answer:</u>

Any formula entered in the excel sheet should begin with “=”. Otherwise excel reads that to be a normal text and it will not process the further to get a “result”.

A formula can be entered either in <em>the cell or in the “formula bar”</em>. Once a formula is entered and an enter key is encountered, the result will be displayed in the <em>cell and connected formula</em> gets displayed in the Formula bar.

When we move the focus over that cell it <em>displays only content and not formula,</em> because formula gets displayed only in the “formula bar”.

7 0
4 years ago
Other questions:
  • Which icon will automatically adjust the amount of space between letters from very tight to very loose in style? Hyphenation, Te
    6·2 answers
  • ROE: what does this represent (in plain terms)? In what range would this number typically be? What type of person/position would
    11·1 answer
  • Write a program in C++ or C that includes two different enumeration types and has a significant number of operations using the e
    15·1 answer
  • Public-key cryptography can be used for encryption (ElGamal for instance) and key exchange. Furthermore, it has some properties
    9·2 answers
  • 2. An evil twin attack that broadcasts a legitimate SSID for an unauthorized network is an example of what category of threat? A
    9·1 answer
  • 2.13) A simple rule to estimate your ideal body weight is to allow 110 pounds for the first 5 feet of height and 5 pounds for ea
    15·1 answer
  • 1. Trust can be built in a relationship if:
    15·1 answer
  • What is the IP address and TCP port number used by the client computer (source) that is transferring the file to gaia.cs.umass.e
    9·1 answer
  • A computing company is running a set of processes every day. Each process has its own start time and finish time, during which i
    11·1 answer
  • 7. Malware could A. cause a system to display annoying pop-up messages B. be utilized for identity theft by gathering personal i
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!