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
Marta_Voda [28]
3 years ago
10

How are static variables and methods created in Java? What happens if a non-static method of a class tries to access a static va

riable of that class? What happens to the static variables of a class once the class has no instances?
Computers and Technology
1 answer:
9966 [12]3 years ago
4 0

Answer:

Static variables are the variables decaraed with keyword static, static variables must be deacraled inside the class body, means we can not declare a static variable inside a method or consttructor, static variable belongs to class, for a class only one copy is created for static variable and used by all the objects/instances.

Static variable can access with class name like

X.i

Static method are the methods defined with static keyword, static method are also part of a class, we can access static meethod using class name like

X.printI()  

Explanation:

class X

{

//to create a static variable we need use static keyword with variable name like

public static int i;

// to create a static method we need to use static keyword while defining a method like

public static void printHello() {

 System.out.println("Hello");

}

/*

 * A non static method can access static variable of a class there is no issue

 * with that we can use a static variable in a non static method like

 */

public void printI() {

 System.out.println(i);

}

/*

 * As long as the class exist in JVM static variables will be there, as static

 * variable belong to class not with the instance,

 * it does not matters if there are instance exist or not

 */

}

You might be interested in
Nathan notices that the words of the quotation are too close to the borders.
Airida [17]

Answer:

c. options

Explanation:

4 0
3 years ago
Read 2 more answers
A mobile phone is responding slowly and erratically for a user. The user has tried a soft reset on the device, but the phone con
lubasha [3.4K]

Answer:

At first try to Restart your device and use it which will close all the running apps and phone can process a bit faster . Other Chances for slow processing can be lack of internal storage so if restart doesn't work then try to do Do Option B.

4 0
3 years ago
In electrical work, resistance is often represented by thea. Greek symbol O.
Elanso [62]

Resistance is often represented by Ω, (pronounced Ohm). The symbol itself is actually omega though, which is the Greek symbol for O.

So your answer is a.

3 0
3 years ago
How do you reflect yourself in the topic (filters)​
Gnesinka [82]
In what topic ?? Please explain more
6 0
3 years ago
Which area of a magazine cover is often important for those shops and stalls that cannot display the entire cover page on a stan
zloy xaker [14]

I think the answer is one fourth.

Because usually only that part is visible in a stand. It usually contains the name of the magazine and a little bit of illustration gives an idea about what it is about.

6 0
3 years ago
Other questions:
  • (Financial application: compound value) Suppose you save $100 each month into savings account with an annual interest rate of 5%
    6·1 answer
  • Help pls<br><br> What type of link is used to call this file?
    5·2 answers
  • Which option can Jesse use to customize her company’s logo, name, address, and similar details in all her business documents?
    6·1 answer
  • IT organizations implement powerful information systems like ERP and SCM that provide centralized data repositories. In addition
    11·2 answers
  • The endocrine system is composed of many parts of the body.<br> a)True<br> b)False
    11·2 answers
  • You can access word's typographic characters with the _______ button on the insert tab
    9·1 answer
  • What do you think is the biggest threat to the security of your personal information?
    5·2 answers
  • Name the error that has happened in the binary addition 0¹01+111=1000​
    6·2 answers
  • Explain the iterative nature of the database requirements collection, definition, and visualization process.
    14·1 answer
  • What happens when you run a program in Python? ​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!