subject

Questions 5 - 7 refer to the following code:

public class Whatchamacallit {
private double price;
private String title;

public Whatchamacallit() {
this (0, "none");
}

public Whatchamacallit(double p, String t) {
price = 0;
if (p > 0) {
price = p;
}
title = t;
}

public String toString() {
return title + " costs $" + price;
}
}
The following code segment appears in another class:

ArrayList list = new ArrayList();

list. add(new Whatchamacallit());
list. add(new Whatchamacallit(3.5, "book"));
list. add(new Whatchamacallit(-17, "CD"));
list. add(new Whatchamacallit(18.95, "sweater"));
list. add(new Whatchamacallit(5, "notebook"));

/* Missing Code */
Suppose the following line is used to replace /* Missing Code */.

System. out. println(list. get(list. size() - 1));
What is printed as a result of executing the code segment?

notebook costs $5.0
CD costs $0.0
book costs $3.5
sweater costs $18.95
none costs $0.0

2nd part of question

Suppose the following lines are used to replace /* Missing Code */.

list. remove(1);
System. out. println(list. get(1));

What is printed as a result of executing the code segment?
none costs $0.0
book costs $3.5
sweater costs $18.95
CD costs $0.0
notebook costs $5.0

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:00
What best describes a career pathway in a lodging career? a worker starts out as an amusement attendant, then becomes a recreation worker, and then becomes a gaming worker within five years. a worker starts out as a bell hop, then becomes a night clerk, and then becomes a hotel manager within five years. a worker starting out as a tour guide, then becomes a travel clerk, and then becomes a travel agent within five years. a worker starts out as a server, then becomes a food preparer, and then becomes a head chef within five years.
Answers: 1
question
Computers and Technology, 22.06.2019 19:20
Write a program that reads a file consisting of students’ test scores in the range 0–200. it should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. output the score ranges and the number of students. (run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189.)
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
What are some ways to use a range name in a formula? check all that apply. in the defined names group, click use in formula, and then select the desired name. begin typing the name in the formula, select a name from the autocomplete list, and use the arrow keys and tab key to enter the name in the formula. begin typing the formula, and then click and drag with the mouse to select the cells to include in the formula. right-click one of the cells in the range. click formula options, and use the dialog box to add the name.
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
You wanted to look up information about alzheimer's, but you were unsure if it was spelled "alsheimer's" or "alzheimer's." which advanced search strategy would be useful? a) a boolean search b) using a wild card in your search c) trying different search engines d) doing a search for "alsheimer's not alzheimer's" asap. ill give brainlist.
Answers: 1
You know the right answer?
Questions 5 - 7 refer to the following code:

public class Whatchamacallit {
privat...
Questions
question
Mathematics, 10.09.2021 01:00
question
Mathematics, 10.09.2021 01:00
question
English, 10.09.2021 01:00
question
Mathematics, 10.09.2021 01:00
question
Mathematics, 10.09.2021 01:00
Questions on the website: 13722367