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
PLEASEEEE HELPPP
zavuch27 [327]
<span>C. real-time operating system</span>
6 0
3 years ago
Which customers are typical for the Argriculture,Food, and Natural Resources career cluster?
Ahat [919]

Ecosystem developers

8 0
4 years ago
If my 98 dodge ram 1500 truck is dropping RPM's when i stop does that mean i need new throttle body sensors or does it mean i ne
geniusboy [140]
You might need a new 02 sensor and i really dont know about the vacuum leak.
6 0
3 years ago
Read 2 more answers
. Use one command to create a /sales directory with the permissions of 770
mars1129 [50]

Answer:

mkdir -m 770 sales

Explanation:

The command mkdir is used to create a directory and the attribute or flag

-m is used to  assign permissions on create a folder.

Example:

mkdir -m 770 sales

Create a folder with permissions 770 with name sales

7 0
3 years ago
What does the process of email encryption involve??
stealth61 [152]

Answer: Option C

Explanation:

4 0
3 years ago
Other questions:
  • PLEASE HELP ITS EASY I JUST BIG STOOPYHEAD!!!!
    5·2 answers
  • Write a MATLAB script that prompts the user to input the following array by providing an example in the prompt: [2 4;6 3;5 9]. C
    15·1 answer
  • What command enables you to initialize quotas on a file system?
    9·1 answer
  • Do debit cards allow you to draw funds directly from your checking accounts
    10·1 answer
  • A common use-case for dictionaries is to store word counts. Let's modify our program below to store the count for each unique wo
    9·1 answer
  • 4. Explain the term prejudice. What is an example of prejudice as it relates to parenting?
    11·1 answer
  • Which king, after finding the decree of Cyrus giving the Jews permission to return and build the Temple, ordered the end of oppo
    11·2 answers
  • If the user inputs “10” for the first expense and “20” for the second expense, what will the interpreter show in the final line
    13·1 answer
  • What type of dns servers field dns queries, send iterative queries to upstream dns servers, or send requests to forwarders and t
    8·1 answer
  • 48
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!