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]
3 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]3 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
Which of the following is not a key component of a structure?
Nezavi [6.7K]
Name
I am not sure about it
8 0
3 years ago
Write a program that calculates the total amount of a meal purchased at a restaurant by a customer. The program should ask the u
Illusion [34]

Answer:

Python script is given below

Explanation:

charge = float(input('Enter the amount you were charged. $'))

#setting the formula for tip and tax

tip = charge*.18

tax = charge*.07

#printing the values

print('Charge for the food: %.2f' % charge)

print('The tip amount: %.2f' % tip)

print('Tax amount: %.2f' % tax)

print('Total amount: %.2f' % (charge+tip+tax))

7 0
4 years ago
True false) ther are five arrow keys on the keborad​
cluponka [151]

Answer:

false, there's only 4

Explanation:

5 0
3 years ago
QUESTION: Which is not an example of a video port or cable?
Vikki [24]

Answer:

Radio Corporation of America (RCA)

Explanation:

A corporation is not a video connector.

8 0
3 years ago
What are the real-life applications of coding?
oksian1 [2.3K]

Some example's of coding affecting real life:

  • Traffic Lights
  • Biometric Security
  • Robots used in factories. can work in extreme conditions.
  • Automatic Heater or Air Conditioner.
  • Expert Systems used in for Medical Use.
  • Smart Self Driving Cars
8 0
2 years ago
Other questions:
  • Cyberterrorism is the use of terrorism to attack (Points : 1) public libraries. computer based networks. government spy networks
    15·1 answer
  • A forensic investigator at a crime lab is performing a forensic analysis of a hard drive that was brought in by state troopers.
    10·1 answer
  • The entire presentation can be seen at a time in __________
    5·1 answer
  • Tom's Art Supplies used to sell art supplies through mail order catalogs, but the company's order takers often had difficulty de
    9·1 answer
  • Nikolas has a idea that he could use the compressed carbon dioxide in a fire extinguisher to propel him on his skateboard. Nikol
    13·2 answers
  • Explain briefly the purpose of the Computer Management Console in Microsoft Windows.
    12·1 answer
  • We have written a method called sum with an int[] parameter nums. We want our sum method to compute the sum of nums, but our cod
    5·1 answer
  • When browsing using certain browsers, if a page is known to be malicious or using phishing techniques in the past a browser may
    5·1 answer
  • What factors do network consultants consider when determining the network needs of a business? Use the space provided below to a
    6·1 answer
  • Plagiarism is considered
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!