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, 21.06.2019 18:00
What is stored in str after the following code executes? string str = "computer science"; int i = 0; while (i < 8) { if (str.indexof("m") < i) { str = str.substring(0, 2) + str; } i += 2; } computer science cocomputer science cococomputer science cocococomputer science computer scienceco
Answers: 3
question
Computers and Technology, 22.06.2019 20:00
How is the number 372 written when expanded out to place values in the base 8 (octal) number system? a. 2 x 4 + 3 x 2 + 4 x 1 b. 3 x 64 + 7 x 8 + 2 x 1 c. 3 x 8 + 7 x 7 + 2 x 6 d. 3 x 100 + 7 x 10 + 2 x 1
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
Which of the following terms refers to a collection of different types of software that share the goal of infiltrating a computer and making it do something? a- malware b- virus c- spyware d- trojan horse
Answers: 2
question
Computers and Technology, 24.06.2019 05:30
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
Answers: 2
You know the right answer?
Questions 5 - 7 refer to the following code:

public class Whatchamacallit {
privat...
Questions
question
Mathematics, 07.01.2021 01:00
question
Mathematics, 07.01.2021 01:00
question
Mathematics, 07.01.2021 01:00
question
Physics, 07.01.2021 01:00
Questions on the website: 13722360