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
Protecting data security, privacy, and integrity are important database functions. What activities are required in the DBA's man
Mrrafil [7]

Answer:

Coordinating, monitoring, and allocating database administration resources

Explanation:

people and data. Defining goals and formulating strategic plans for the database administration function.

Separate database servers and web servers.  

Use web application and database firewalls.  

Secure database user access.  

Regularly update your operating system and patches.  

Audit and continuously monitor database activity.  

Test your database security.  

Encrypt data and backups.

The DBA are responsible to authorizing access the database, coordinate and monitor, and acquiring software/ hardware resources. The database designers are responsible to identify the data that to be stored in the database and choose suitable structures to store this data.

Software installation and Maintenance.

Data Extraction, Transformation, and Loading.

Specialized Data Handling.

Database Backup and Recovery.

Security.

Authentication.

Capacity Planning.

Performance Monitoring.

7 0
3 years ago
Care and feeding for computer
o-na [289]
Don’t drop it and charge it regularly
5 0
3 years ago
Which ipv6 header field is known as the priority field?
Yuki888 [10]
<span>Traffic Class header field is known as the priority field.</span>
4 0
3 years ago
Read 2 more answers
Telepresence provides the opportunity for people to work from home and attend virtually. True False
ira [324]
The answer is true.
Telepresence is essentially things like video-chat that allows people to participate in meetings even if they are not physically present.

I hope this helps! :)
~ erudite 
7 0
3 years ago
Read 2 more answers
Can you repeat 10th grade if you need too and want too.
blondinia [14]

Im pretty sure you can but different schools have different rules so try contacting your guidence counselor and asking them

7 0
3 years ago
Read 2 more answers
Other questions:
  • Which element of a business document provides additional information but is not a part of the body of the text?
    13·2 answers
  • A result of the Gibbons v. Ogden (1824) decision was that states​
    11·1 answer
  • Consider the following implementation of a class Square:
    12·1 answer
  • If you delete a sent message on gmail does the person still get it
    14·1 answer
  • Which statement best describes a transition in PowerPoint?
    12·1 answer
  • Where is the worlds biggest cookie​
    7·2 answers
  • How many Iron molecules are in the compound Fe4O2?
    15·2 answers
  • How to get bing with any node unblocker
    10·2 answers
  • Stay safe and search answers up if you need ​
    14·1 answer
  • Icon view, list view, and details view are all common views provided by which kind of program?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!