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
zimovet [89]
2 years ago
9

Assume that you have an ArrayList variable named a containing 4 elements, and an object named element that is the correct type t

o be stored in the ArrayList.
Which of these statements adds the object to the end of the collection?1. a[3] = element;
2. a.add(element;
3. a[4] = element;
4. a.add(element);
Computers and Technology
1 answer:
jonny [76]2 years ago
7 0

Answer:

Option (4) is the correct answer.

Explanation:

In Java programming language ,array collection starts from 0 index location and ends in a size-1 index location. So to access the last elements the user needs to use a[Size-1] statement. so to modify the value of the last location of the array the user needs to use "a[size-1]= element;".

But when the user wants to add some new value to the end of the array list collection then he needs to use the statement--

a.add(element); //where add is a function, element is a value and a is a array list object.

Another option is invalid because--

  • Option 1 is not the correct because "a[3]=element;" modify the value of the 3rd element of the array.
  • Option 2 gives a compile-time error because add functions bracts are not closed.
  • Option 3 gives the error because a[4] gives the location of the 5th element of the array but the above question says that a is defined with 4 elements.
You might be interested in
Adam is so good at playing arcade games that he will win at every game he plays. One fine day as he was walking on the street, h
klio [65]

Answer:

what the answer chaoices

Explanation:

brainlest me please

3 0
3 years ago
A computer's CPU and hard drive are found in the
Galina-37 [17]
A computers CPU and the hard drive are found in the system unit. The correct answer is C. <span />
8 0
3 years ago
Read 2 more answers
Write an if statement that prints the message “Application accepted” if the variable workExperience is greater than or equal to
katovenus [111]
If workExperience >= 2 or CollegeDegree is true:
print “Application accepted”
else:
print “Application denied”

4 0
3 years ago
Read 2 more answers
A firewall relies on or a that determine what traffic should or should not be allowed to pass through
likoan [24]
A firewall determines what external network traffic(internet) should or should not be allowed to pass internal network(computer). A firewall is network security that protects software and hardware from untrusted sites that may have viruses, worms, and bugs that are detrimental to the computer.
5 0
3 years ago
A loop decision point for an algorithm consists of three features: an initial value, a set of actions to be performed, and a(n)
pychu [463]

Answer:

Option c is the correct answer for the above question.

Explanation:

A loop is used to repeat some lines in some specific times which depends on some conditions of the loop. If a person wants to print "welcome" on 5 times then he can do this by two ways one is writing a print statement 5 times and the other is states a loop that executes 5 times through condition. The loop is described or written by three necessary points which are:-

  1. The fist is to initialize the initial value which tells the compiler for the starting point of the loop.
  2. The second is to any action for that condition variable which takes the loop for the direction of ending points.
  3. The third is a condition that defines the ending point of the loop.

The above question also states about the loop in which first and second points are given then the third point is necessary to complete the sentence which is states in option c. Hence the option c is correct while the other is not because--

  • Option 'a' states about the class operator which is not the part of the loop.
  • Option b states about the documentation plan which is also not the part of the loop.

5 0
3 years ago
Other questions:
  • Which Command Prompt commands in Windows is used for listing a computer connections to shared resources
    10·1 answer
  • You and your friend play a video game where a superbird has to find and eat radiation leaks at nuclear power plants before the p
    13·2 answers
  • According to the Doppler effect, objects moving away from Earth would have a
    12·2 answers
  • A ________ is a self-contained program that spreads through a computer network by exploiting security holes in the computers con
    9·1 answer
  • Extend to also calculate and output the number of 1 gallon cans needed to paint the wal. Hint: Use a math function to round up t
    12·1 answer
  • True or False? PPOs differ from HMOs because they do not accept capitation risk and enrollees who are willing to pay higher cost
    10·1 answer
  • The Internet was first used by which of the following institutions?
    7·1 answer
  • Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input
    5·1 answer
  • Language modeling incorporates rules of __. Select all that apply.
    7·1 answer
  • Firewalls are available as a special hardware device or as software. A firewall will block packets of information that are from
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!