1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
shusha [124]
3 years ago
10

How can an instance variable be used in a class? Explain your answer. (java)

Computers and Technology
1 answer:
melamori03 [73]3 years ago
7 0

Answer:

Instantiate the object and access the variable using object reference.

Explanation:

In order to use/access an instance variable in a class, the class needs to be instantiated.For example:

class Demo{

    //Instance variable declaration

    int testvar=0;

    public static void main(String args[]){

          //Class instantiation

          Demo d = new Demo();  

          // The instance variable is accessed using the object reference

          d.testvar = 1;

    }

}

In case the instance variable in private then it can be accessed using its corresponding getter/setter methods.

You might be interested in
Which of the following statements is used to terminate the program when closing the frame?
blondinia [14]

Answer:

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

Explanation:

JFrame is the swing class that is used to display a frame object. The JFrame display contains an X button on the top right position which is used to turn off the display of the frame. However if we want to terminate the program on pressing the X button, we need to update the DefaultCloseOperation for the frame. JFrame provides a method ''setDefaultCloseOperation' for this purpose. When this method is called with the argument JFrame.EXIT_ON_CLOSE , it will cause the program to exit when the close button is pressed.

4 0
4 years ago
What is the computer's main memory, which consists of the random access memory (ram), cache memory, and read-only memory (rom) t
Nata [24]
Hey there!

The main memory of a computer that includes RAM, ROM, and cached information that is accessible through the CPU is called primary storage. These memory/storage types deal directly with how the computer functions and runs. The other type of storage is called secondary storage and refers to storage that isn't directly connected to the CPU, such as the hard drive. 

Hope this helped you out! :-)
5 0
3 years ago
In last week's meeting we discussed long and short term costs associated with build an buy scenarios using a house as an example
dedylja [7]

Answer:

Custom software designs a software package that is targeted to a particular user community and that meets an organization's specific needs. A lot of these things must be taken into account whenever making a "buy vs. create" decision for a custom software.

Purchasing a wrong program may hinder the process for your business while trying to build one can be expensive and time consuming. The study of these two methods should take into account labor costs, long-term and brief-term costs, and infrastructure costs.

The most popular purpose an organization creates or gets a custom product is that it's special to their organization and if the software is designed effectively it will improve the business' productivity and create its own competitiveness edge.

Moreover, creating a custom software requires a great upfront cost and it also takes a long time to build a proper one.

Labor costs for developing a customized product are often greater than purchasing off-the-shelf solution, as the company has to employ a software developer and build an IT team to create and manage the right software.

There would be maintenance costs in the long run but it wouldn't be as enormous as it was in the building and the process of creation. But, the more significant than cost, is the long-term benefit it brings to the business.

A specific application will improve the workflow of the company, allow the company to retain space with the rate and volume expansion, all of which would help bring financial benefits and distinguish the business from other competitors.

4 0
3 years ago
You can print powerpoint presentation handouts with up to ____ slides per page.
Ierofanga [76]
You can print up to 9 slides per page.
3 0
4 years ago
Any three types of financial assistance that can be applied for after grade 12 to Study​
Romashka-Z-Leto [24]
Grants and scholarships
3 0
3 years ago
Other questions:
  • Which resource helps a user access a cloud service?
    13·2 answers
  • What are the advantages and disadvantages of using thermoset plastics
    14·1 answer
  • Adjusting the ______ adjusts the difference in appearance between light and dark areas of the photo.​
    6·1 answer
  • A _____ is inserted so that a portion of a document that can have different formatting from the rest of the document. a. heading
    9·1 answer
  • The __________ format is a proprietary file format defined by guidance software for use in its forensic tool to store hard drive
    15·1 answer
  • A chemical mixture that is burned to produce thrust. (Jet engine homework)
    14·2 answers
  • Both Wireshark and NetWitness Investigator can be used for packet captures and analysis. Which tool is preferred for each task,
    13·1 answer
  • 1. Microsoft Excel, MS Excel, or simply Excel is a______application by Microsoft Corporation. 2. Excel allows you to organize an
    13·1 answer
  • Does anyone know the answer
    10·1 answer
  • Imagine an everyday scenario in which you are using the internet: downloading a file, uploading a photo, checking your email, et
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!