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
Write a simple hello world program in python 3
IRINA_888 [86]

Answer:

print("hello world")

Explanation:

a hello world program is simply a program that prints out hello world.

for this you would need to remember to have the same number of brackets on each side and to write print. Also remember when printing to include speech marks.

6 0
3 years ago
Read 2 more answers
20<br>Calculate the kinette energy of a body the speed<br>that will be a mass tragm​
jolli1 [7]

Answer:

20

Explanation:

4 0
3 years ago
What value will be stored in the variable t after each of the following statements
olga55 [171]

Answer:

A) t = true

B) t = false

C) t = false

D) t = true

Explanation:

Part A, here 12 is greater than 1 so the condition is true.That is why "t" will hold "true".Part B, here 0 is not greater than 2 so this condition fails.Therefore "t" will hold "false" in this case.Part C,3*2=6 and we are comparing 5 with 6  Therefore condition fails here.That is why "t" will hold "false".Part D, here  we are comparing 5 with 5 and both are equal.So "t" will hold "true".

7 0
3 years ago
What are the uses of navigation keys​
Zolol [24]
The navigation keys allow you to move the cursor, move around in documents and webpages, and edit text.
3 0
2 years ago
Two different names that refer to the same data item best defines:
Nezavi [6.7K]
You could call that a reference or a pointer.
5 0
3 years ago
Other questions:
  • When communicating with a server on another subnet, which of the following settings is used to determine which direction it need
    6·1 answer
  • How are computers used in producing weather forecasts?
    8·1 answer
  • As you are talking to your colleague over the phone, the sound of an airplane flying low drowns out part of your conversation. I
    11·1 answer
  • Cookies Are Us runs a series of 100 cookie stores across the Midwestern United States and central Canada. At the end of each day
    13·1 answer
  • List the four types of hardware​
    10·1 answer
  • write a program that inputs 3 numbers and prints the largest input must be transformed into a integer but printed as a string​
    11·1 answer
  • Question 8 of 10
    12·1 answer
  • Consider the following recursive method.
    14·1 answer
  • You and a friend have just started a small business. How could you use the Internet to make your business successful?
    15·2 answers
  • please help me out i’ll give you brainlist
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!