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
A ________ is s field or set of fields in a record that uniquely defines the record.
Archy [21]
A primary key is the answer. =)
5 0
3 years ago
Drag each tile to the correct box.
Arte-miy333 [17]

Answer:

Explanation:

web server= stores text, images, and other media that make up a website

email server= stores and exchanges messages

Proxy server= filters content and stores data for faster access

FTP server= stores and provides files for download

7 0
2 years ago
Read 2 more answers
Type the correct answer in the box. Spell all words correctly. How is it possible to access data from any location? Storing data
romanna [79]

Answer:

optical

Explanation:

The earliest of these was the magnetic device. Computer systems began with magnetic storage in the form of tapes (yes, just like a cassette or video tape). These graduated to the hard disk drive and then to a floppy disk.

5 0
3 years ago
A semiconductor kit is used on a
iragen [17]

The correct answer is PSC motor.

If you need more help, you can check on quizlet, I learnt about ecd from there lol

5 0
3 years ago
The quality of an image is compromised when, what are stretched ?​
german

Answer:

pixels

Explanation:

3 0
3 years ago
Other questions:
  • Lionbridge theory test
    6·2 answers
  • manufacturers are making an effort to build energy-efficient computers and use recyclable cases and packaging true or false
    10·1 answer
  • Outcomes resulting from using incorect requirement specification during system development​
    11·1 answer
  • After you enter the details for the first selected recipient in the New Address List dialog box, click _______ to add another re
    9·1 answer
  • Before you can use the Management Studio to work with the objects in a database, you must ___________ the database files (i.e.,
    9·1 answer
  • 1. Which of the following statements are true about routers and routing on the Internet. Choose two answers. A. Protocols ensure
    9·2 answers
  • Short Essay on the history of Computer​
    6·2 answers
  • Identify examples of loop structures using comments in your code. Be sure your examples address each of the following: i. Item-b
    6·1 answer
  • HELP PLEASE
    14·1 answer
  • Different Betweens ServerPc And Desktop Pc ~
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!