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
Please help me please it's urgent​
il63 [147K]

Answer:

age = input()

if age < 13:

   print("Not allowed")

else:

   print("Allowed")

7 0
3 years ago
What are the characteristics of a good text-based adventure game? In other words, what are some features that should be in the g
Degger [83]

Answer:

spelling and good format

Explanation:thats all i know

8 0
3 years ago
A ____ is any key that uniquely identifies each row.
Mrac [35]
<span>A _superkey___ is any key that uniquely identifies each row.</span>
6 0
3 years ago
Which of the following is an advantage of text HTML editors over plain text editors?
zubka84 [21]
C hope that helps have a good day and I feel you good for big hugs
5 0
3 years ago
Read 2 more answers
Part of preforming routine computer maintenance includes
omeli [17]
Cleaning And tidy cords
7 0
3 years ago
Read 2 more answers
Other questions:
  • Find the cell address of first column and last row some one pls answer :'(​
    9·1 answer
  • You are to create a program using Python that asks the user for a nonnegative number, then computes the mean and variance using
    15·1 answer
  • An Internet user has a need to send private data to another user. Which of the following provides the most security when transmi
    15·2 answers
  • _____ is a program that allows a person using one computer to access files and run programs on a second computer that is connect
    11·1 answer
  • "What technology will examine the current state of a network device before allowing it can to connect to the network and force a
    6·1 answer
  • ---------------is a systematic review of a person’swork and achievements over a recent period, usually leading toplans for the f
    11·1 answer
  • . Write a C++ Code to get a multiline statement Str1 from a user with a ‘$’ as return character (Hint:
    6·1 answer
  • Why is science, mathematics, and technology different from engineering?
    15·1 answer
  • Neview of related literature happens in two wayo (1) Traditional and
    6·1 answer
  • Describe the specific job you would want to have if you were going to pursue a career in digital music or video.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!