Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you try to help me on this programming problem? Fig 3.1 and Fig 3.2 thank you... 3.2 Instance Variables, set Methods and get Methods

Can you try to help me on this programming problem? Fig 3.1 and Fig 3.2 thank you... image text in transcribed
image text in transcribed
3.2 Instance Variables, set Methods and get Methods 7I Typically, the apps you develop in this book will consist oftwo or more classes. If you become part of a development team in industry, you might work on apps that contain hundreds, or even thousands, of classes. 3.2 Instance Variables, set Methods and get Methods In this section, you'll create two classes Account (Fig. 3.1) and AccountTest (Fig. 3.2) Class AccountTest is an application class in which the main method will create and use an Account object to demonstrate class Account's capabilities 3.2.1 Account Class with an Instance Variable, a set Method and a get Method Different accounts typically have different names. For this reason, class Account (Fig. 3.1) contains a name instance wariable. A class's instance variables maintain data for each object (that is, each instance of the class. Later in the chapter we'll add an instance variable named balance so we can keep track of how much money is in the account. Class Account con- tains two method setName stores a name in an Account object and method getName obtains a name from an Account object. I Fig. 3.1: Account java 2 Account class that contains a name instance variable 3 and methods to set and get its value. 5 public class Account 7 private String name instance variable 9 method to set the name in the object lo public void setNameCString name) this name name: store the name 14 15 method to retrieve the name from the object public string getNameo return name: return value of name to caller 20 end class Account Fig. 3. I l Account class that contains a name instance variable and methods to set and get its value. Class Declaration The class declaration begins in line 5: public class Account The keyword public (which Chapter 8 explains in detail) is an access modifier. For now, we'll simply declare every dass public. Each public class declaration must be stored in a file having the same name as the class and ending with the java filename extension: otherwise

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

=+ Are unions company-wide, regional, or national?

Answered: 1 week ago

Question

=+j Explain the litigation risks in international labor relations.

Answered: 1 week ago

Question

=+j What rules will apply to the process of negotiations?

Answered: 1 week ago