![davelopez979](/avatars/22574.jpg)
davelopez979
05.05.2020 •
Computers and Technology
Class Product {
double price;
}
public class Test {
public void updatePrice(Product product, double price) {
price = price *2;
product.price=product.price + price;
}
public static void main ( String args[]) {
Product prt = new Product();
prt.price=200;
doucble newPrice = 100;
Test t = new Test ();
t.updatePrice ( prt, newPrice);
System.out.println(prt.price + " : " + newPrice);
}
}
What is the result?
A) 200.0: 100.0
B) 400.0: 200.0
C) 400.0: 100.0
D) Compilation fails.
Solved
Show answers
More tips
- L Leisure and Entertainment Choosing the Right Books to Read: Tips and Recommendations...
- L Leisure and Entertainment What can be considered an antique: defining and valuing old objects...
- B Business and Finance How to Open an Online Store? A Detailed Guide for Beginners...
- C Computers and Internet Log-in: what is it and why do you need it?...
- C Computers and Internet What is the Meaning of lol and How Did it Become Popular?...
- C Computers and Internet Clearing Cache: How to Speed Up Your Browser...
- H Health and Medicine How to Help Men Gain Weight?...
- F Family and Home How to Build a Strong Relationship with Your Child: Tips for Effective Communication...
- L Legal consultation Juvenile Justice: Who Needs It?...
- F Food and Cooking What age is appropriate for giving your child cocoa?...
Answers on questions: Computers and Technology
- C Computers and Technology A student is conducting an experiment in which he adds an inhibitor to an enzyme-catalyzed reaction that contains alkaline phosphatase. When the student first adds the inhibitor,...
- S Social Studies A(n) reinforcer refers to the removal of an unpleasant stimulus, putting on a sweater when you re cold for example, which leads to an increase in the probabilitythat a preceding...
- H Health A student applying for clinical psychology graduate programs would likely select a program adhering to the model of training if he or she wished to primarily engage in clinical...
- B Biology Sadie s continued use of marijuana will lead to her brain s reduction of the neurotransmitter , which will require her to need more of the marijuana to achieve its effects....
- M Mathematics A clock is constructed so that it keeps perfect time when its simple pendulum has a period of exactly 1.000 s. The pendulum bob has length L = 0.2489 m and, instead of keeping...
- H Health The nurse assesses a patient who complains of loneliness and episodes of anxiety. Which statement by the patient is mostly likely if this patient also has agoraphobia? a. I...
- C Chemistry Convert 298.8 K to °C. Enter the correct number of significant figures....
- M Mathematics Find the median and mean of the data wich reflects the best measure of the center...
- M Mathematics If xto the power of 2 = 50, what is the value of x?...
- E English Select the words and phrases that best develop a positive tone toward Guapo in the passage below. Va cat named Guapo. He is always Your neighborhood, looking for delicious bits...
Ответ:
D. Compilation Fails
Explanation:
There is an error in the program, which if not correct will hinder the successful compilation of the program and will give a compilation error
The error is at doucble newPrice = 100;
The data type has to be spelt correctly to ensure the program is executed successfully
To declare variable newPrice of type double and also initialize it to 100, the right syntax is double newPrice = 100;
After correcting the error, the program will run correctly and produce the following result:
400.0 : 100.0
At line 2 of the main method, an instance of class Product is declared "Product prt = new Product();"
This allows values to be passed between the main method and the class
In class Test
price takes its value from newPrice (in the main method)
So, when newPrice is 100.0
price = 100.0 * 2
price = 200.0
After which product.price is calculated
product.price takes its value from prt.price (in the main method)
So, when prt.price is 200.0
product.price=product.price + price (Recall that price is 200.0; as illustrated above)
product.price = 200.0 + 200.0
product.price = 400.0
At line 5 of the main method, an instance of class Test is declared "Test t = new Test ();"
The next line t.updatePrice ( prt, newPrice); assigns the calculated values to prt and newPrice respectively
prt = 400.0
newPrice = 100.0
The output is done on the next line: System.out.println(prt.price + " : " + newPrice);
prt.Price = prt = 400.0 and newPrice = 100.0
Hence, the output will be done in the following order 400.0 : 100.0
Ответ:
insert quote
*When your awake and it's 3am and you still hear the neighbors loud music. And then you hear someone scream "Empieza la fiesta cuhh!!!"*