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 good algorithm should have which three components?
DiKsa [7]

A good algorithm should have these three components: C. steps, order, and outcomes.

<h3>What is an algorithm?</h3>

An algorithm simply refers to a standard formula which is made up of a set of finite steps and instructions that are executed on a computer system, in order to enable a software solve a particular problem under appropriate conditions.

In Computer technology, there are three (3) components that a good algorithm should have these include the following:

  • Steps
  • Order
  • Outcomes

Read more on algorithm here: brainly.com/question/24793921

#SPJ1

5 0
1 year ago
The Open Systems Interconnection (OSI) Reference Model: defines standards for many aspects of computing and communications withi
Advocard [28]

Answer:

is a generic description for how computers use multiple layers of protocol rules to communicate across a network.

Explanation:

OSI model stands for Open Systems Interconnection. The seven layers of OSI model architecture starts from the Hardware Layers (Layers in Hardware Systems) to Software Layers (Layers in Software Systems) and includes the following;

1. Physical Layer.

2. Data link Layer.

3. Network Layer.

4. Transport Layer.

5. Session Layer.

6. Presentation Layer.

7. Application Layer.

Hence, the Open Systems Interconnection (OSI) Reference Model is a generic description for how computers use multiple layers of protocol rules to communicate across a network.

Additionally, each layer has its unique functionality which is responsible for the proper functioning of the communication services.

8 0
2 years ago
“Urban Populations” should fall under which sections of your organizer?
ELEN [110]

Answer:

a = TOPIC

Explanation:

4 0
3 years ago
Read 2 more answers
Mechanisms that combine memory, processing speed, and knowledge to regulate the analysis and flow of information within the info
gizmo_the_mogwai [7]

Answer:

control processes.

Explanation:

Mechanisms that combine memory, processing speed, and knowledge to regulate the analysis and flow of information within the information-processing system are referred to as executive/control processes.

3 0
3 years ago
Henry has to create software that manages a database of all his clients of his firm. He wishes to run software on another comput
soldi70 [24.7K]

Answer:

The answer is B.

Explanation:

8 0
2 years ago
Read 2 more answers
Other questions:
  • I want to know all part of computer system?
    9·2 answers
  • How can you create the first row of the table as the header of the table?
    14·2 answers
  • How does the binary numbering system differ from the hexadecimal numbering system?
    14·2 answers
  • Name two materials that we can burn in order to get energy from biomass
    9·1 answer
  • Johnathan was assigned to complete a project with three other people. What benefit will he get from working with the team?
    15·1 answer
  • Face book suggests Friends for users based on their
    13·1 answer
  • quiz Flavio visits a local coffee shop on his way to school and accesses its free Wi-Fi. When he first connects, a screen appear
    7·1 answer
  • Girls question <br> who wants to go out ;p
    11·2 answers
  • Direction: Write True on the line if the statement is correct. Write False if the statement is incorrect. 1. All objects are com
    13·2 answers
  • Which website offers guidance on putting together a checklist to provide guidance on configuring and hardening operating systems
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!