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
Software engineering design teams use ________, which are grounded in mathematical concepts of sets and relations, for their sof
zloy xaker [14]

Answer:

Relational Databases

Explanation:

These are digital databases that are made to recognize relations between previously stored items of info.

4 0
2 years ago
Whoever answers first gets lots of points
zimovet [89]
Firssstttttt ayyyyyyeeeeeeeeeeeee
8 0
2 years ago
Read 2 more answers
Blender is used by which video game team member?
prohojiy [21]

Answer:

The 2nd one

Explanation:

6 0
3 years ago
Which programming language was released first? FORTRAN BASIC Perl Pascal<br><br>ANSWER: FORTRAN (A)
julsineya [31]

Answer:

FORTRAN

Explanation:

  • The first programming language was FORTRAN .
  • It was released on 1957
  • About 65 years ago , when programming languages are at infant stage
8 0
1 year ago
Read 2 more answers
what is the molarity of a solution prepared by dissolving 15.0g of sodium hydroxide in enough water to make a total of 225 ml of
Reptile [31]

Answer:

1.6666 g/mol = 1 \frac{2}{3} g/mol

Explanation:

Molar mass of NaOH= 23+16+1 =40g/mol

Mols in 15g = 15/40 mol

If this was dissolved in 225ml of water molarity of the solution is

\frac{15}{40} ÷ 225 x 1000 = 1.6666 g/mol = 1 \frac{2}{3} g/mol

5 0
3 years ago
Other questions:
  • How does technology set a negative impact on the adolescent of our society?
    14·1 answer
  • What is a color that cannot be created by mixing other colors together?
    15·2 answers
  • How many 16ths are in 3/8 of an inch
    12·1 answer
  • Working together, printer A and printer B would finish the task in 24 minutes. Printer A alone would finish the task in 60 minut
    8·1 answer
  • 1. cybersquatting refers to the tampering of existing web sites and selling unrelated products (true or false)
    8·1 answer
  • Witch of the following is a valid why a scientist might a scientific theory
    13·1 answer
  • Which statement best describes antivirus software?
    13·1 answer
  • Suppose that a disk drive has 5,000 cylinders, numbered 0 to 4,999. The drive is currently serving a request at cylinder 2,050,
    14·1 answer
  • 8. A sprite is a simple spider shaped thing with n legs coming out from a center point. The angle
    10·1 answer
  • If a file you are opening for appending does not exist, the operating system will detect the missing file and terminate the oper
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!