After executing the following code what gets printed to the
Solution
Answer 4 -
The Output Will be 20,10,10,
this will be the output because we created an array list which stores integers in the array list first we added 5 to the 0 th position but after that we added 20 on the 0th position by mentioning the in the parameter list so 5 gets replaced by 20 after that we added 10 to the list so it will be added of the next position that is the 1st index of the array list after that we set 10 on the 1st position so it will not replace it as it is the same integer it will add that 10 on the next subsequent position and then we added 2 on the 3 rd position but then we used remove also with size-1 so the integer 2 will be removed from the array list and the remaining integers in the list will be printed .
So the output will be 20,10,10
----------------------------------------------------------------------------------------------------------------------------------------------------------------------.
Question 5-
answer 5a-
class Car
{
double price=999.900;
String owner;
int doors;
Car(int price, String owner, int doors)
{
this.price=price;
this.owner=owner;
this.doors=doors;
}
}
