a. is the amount and the balance the same? yes or no, why? class CheckingAct {   . . . .   private int    balance;     public void processCheck( int  amount )   {                              int amount;          incrementUse();     if ( balance < 100000 )       amount = 15;                    // which amount ???     else       amount = 0;                     // which amount ???       balance =  balance -  amount ;    // which amount ???   } }               b. is the balance the same? yes, no? why?   class CheckingAct {   . . . .   private int balance;     . . . .   public void processDeposit( int amount )   {     int balance = 0;                // New declaration of balance.     balance = balance + amount ;    // This uses the local variable, balance.   } }

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter10: Classes And Objects
Section: Chapter Questions
Problem 6RQ: A Private variable in a class can be accessed directly by a Public method in the same class. a. True...
icon
Related questions
Question

a. is the amount and the balance the same? yes or no, why?

class CheckingAct

{

  . . . .

  private int    balance;

 

  public void processCheck( int  amount )

  {                         

    int amount;   

 

    incrementUse();

    if ( balance < 100000 )

      amount = 15;                    // which amount ???

    else

      amount = 0;                     // which amount ???

 

    balance =  balance -  amount ;    // which amount ???

  }

}

 

 

 

 

 

 

 

b. is the balance the same? yes, no? why?

 

class CheckingAct

{

  . . . .

  private int balance;

 

  . . . .

  public void processDeposit( int amount )

  {

    int balance = 0;                // New declaration of balance.

    balance = balance + amount ;    // This uses the local variable, balance.

  }

}

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning