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
What's the name of the file mainly used to save power point
son4ous [18]
.PPT is the extention for the files downloaded from Powerpoint.
7 0
3 years ago
Read 2 more answers
Explain one thing you will start doing as a passenger.
Diano4ka-milaya [45]

By definition we have to:

The passenger is every human being transported in a means of transport. (Except for the driver.)

Passengers can carry suitcases, bags or backpacks to carry their belongings from one place to another on their trip.

For safety, the first thing passengers must use in any means of transport is the safety belt.

This protects you from accidents that may occur during the trip.

Answer:

As a passenger, the first thing you would do is wear a seatbelt.

5 0
3 years ago
Read 2 more answers
It is ethical to use ICT in early years
Dahasolnce [82]
Early years of what? ICT is generally ethical as it’s just stressing unified communications of different telecommunications/IT devices
3 0
3 years ago
A person attempts to access a server during a zone transfer to get access to a zone file. What type of server is that person try
DerKrebs [107]

Answer: DNS Server

Explanation:

DNS server is the server that has the database along with the IP addresses along with names of the host as well in a computer system. So, by accessing the zone file , the person is actually trying to manipulate the host that is present in the DNS server zone. DNS server helps in the execution of the particular software and maintaining the connection using some protocols.

4 0
3 years ago
After the following code runs, what will be the value of result? var x = 30; function get () { return x; } function set (value)
PilotLPTM [1.2K]

Answer:

Null

Explanation:

It entirely depends on the language you are using to implement this.

But generally by the rule of scope, "result" will return null since get() was not defined to accept any argument, and it neither know the global "x" not defined it's own x in the function.

5 0
3 years ago
Other questions:
  • What does no technical solution problems mean answers?
    12·1 answer
  • How can I make a website login system with only using php?
    14·1 answer
  • Implement the Dining Philosophers problem (described on pages 167-170 in the textbook (chapter 2.5.1)). Create a Graphical User
    13·1 answer
  • How is communication within healthcare different than communication within other industries ?
    13·1 answer
  • 1. What does VolP stand for? *
    10·2 answers
  • What is better for a samsung tab a7 a 32 gb or 64
    14·1 answer
  • 1110011*110011 binary multiplication
    9·2 answers
  • Internet privacy refers to the level of information sharing on the web collected through web cookies, caches, and browsing histo
    7·1 answer
  • The involvement of the United States in the ______ and ______ resulted in _______ .
    15·1 answer
  • a transport layer security (tls) virtual private network (vpn) requires a remote access server listening on port 443 to encrypt
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!