Question: Consider a form that has two buttons: btnComputeCost: computes the sub total and total cost for an order. btnDisplay: intended to display the sub total

Consider a form that has two buttons:
btnComputeCost: computes the sub total and total cost for an order.
btnDisplay: intended to display the sub total in a ListBox named lstDisplay.
The click event handlers of the two buttons look as follows:
private void btnComputeCost_Click(object sender, EventArgs e)
{
//(statements to declare and assign values to unitPrice and number of
//scoops go here)
double subTotal;
subTotal = unitPrice * scoops;
//(statements to compute total cost go here)
}
private void btnDisplay_Click(object sender, EventArgs e)
{
lstDisplay.Items.Add(subTotal.ToString());
}
The following statement is true about the variable subTotal:
Consider a form that has two buttons:
btnComputeCost: computes the sub total and total cost for an order.
btnDisplay: intended to display the sub total in a ListBox named lstDisplay.
The click event handlers of the two buttons look as follows:
private void btnComputeCost_Click(object sender, EventArgs e)
{
//(statements to declare and assign values to unitPrice and number of
//scoops go here)
double subTotal;
subTotal = unitPrice * scoops;
//(statements to compute total cost go here)
}
private void btnDisplay_Click(object sender, EventArgs e)
{
lstDisplay.Items.Add(subTotal.ToString());
}
The following statement is true about the variable subTotal:
A. the statement that displays subTotal within lstDisplay_Click is invalid because the variable subTotal cannot be accessed from lstDisplay_Click method.
B. subTotal can be accessed from any statement (before or after its declaration) within the method, btnComputeCost_Click
C. subTotal can be accessed only from statements that follow its declaration within the method, btnComputeCost_Click
both A and C are true

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 Databases Questions!