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
Comments can be hidden by clicking the _____ button.
Tamiku [17]
C because previous sends you back to something before such as a web page, Next does the opposite and I can't remember what Show MarkUp does.

5 0
3 years ago
Which is the most visual social media site?
Aleks04 [339]
Enge extrapolated this analysis across the 2.2 billion<span> users on Google and concluded that while the “active profiles” on Google+ amount to </span>111 million<span> users, only 6.7 million users have 50 or more posts ever, and only 3.5 million have 50 or more posts in the last 30 days</span>
3 0
3 years ago
Edhesive 7.2 code practice Write a function named ilovepython that prints out I love Python three times. Then, call that functio
Marysya12 [62]

Answer:

def i_love_python():

   for _ in range(3):

       print("I love Python")

i_love_python()

Explanation:

3 0
2 years ago
Thanks to ____ files, a website can recognize you and cater to your individual tastes each time you visit.
Licemer1 [7]
Saved files now and days
4 0
3 years ago
The convergence of information technology and operations technology, offering the potential for tremendous improvements in effic
11111nata11111 [884]

Answer:

<em>e. Industrial Internet of Things</em>

Explanation:

The industrial Internet of Things (IIoT) <em>is the use of intelligent detectors and actuators to improve manufacturing processes and production. </em>

IIoT utilizes the power of intelligent machines and real-time big data to take full advantage of data produced for years by "dumb" machines in industrial settings.

7 0
3 years ago
Other questions:
  • Which presentation software element can you use to create a model diagram with two concentric circles inside a triangle?
    10·2 answers
  • Which OS function does a CLI fulfill? A User interface B Running applications C Hardware interface D Booting
    8·1 answer
  • Categories of general purpose application software and examples each​
    13·1 answer
  • Which skill refers to the ability to visualize and implement possible business solutions to problems?
    6·1 answer
  • A simulation model includes: a. a description of the components of the system. b. a simulation clock. c. a definition of the sta
    8·1 answer
  • Which type of virus includes protective code that prevents outside examination of critical elements?
    14·1 answer
  • The Python print function
    9·1 answer
  • Where do you define parameter variables?
    14·1 answer
  • Which statement gives an advantage of multicellular organisms?
    7·2 answers
  • What programming language supports relational databases?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!