Question: what is displayed by the following code segment? public class Book { private double cost, retail; private boolean fiction; private void setRetail ( ) {

what is displayed by the following code segment?
public class Book {
private double cost, retail;
private boolean fiction;
private void setRetail(){
if(fiction)
retail = cost *2.0;
else
retail = cost *1.5;
}
public Book(double c, boolean f){
cost = c;
fiction = f;
retail = cost;
}
public double getRetail(){
setRetail();
return retail;
}
public static void main(String[] args){
Book myBook = new Book(10.0, true);
System.out.println(myBook.getRetail());
}
a.12.0
b.18.0
c.24.0
d. none of these

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!