---
title: "What is static method in java?"  
description: "What is static method in java?"  
author: "Anonymous User"  
published: 2015-03-26  
updated: 2020-09-16  
canonical: https://www.mindstick.com/interview/2362/what-is-static-method-in-java  
category: "java"  
tags: ["java"]  
reading_time: 3 minutes  

---

# What is static method in java?

**The static keyword in java i**s used for memory management mainly. We can apply java static keyword with variables, methods, blocks and nested class. The static keyword belongs to the class than instance of the class. java static methods can be called without creating an object of class. Have we noticed why we write static keyword when defining main it's because program execution begins from main and no object has been created yet. Consider the example below of static methods.\

```
class programming {  public static void main(String[] args) {    display();  }   static void display() {    System.out.println("Java is my favorite programming language.");  }}
```

\

## Answers

### Answer by Anonymous User

If you apply static keyword with any method, it is known as static method.

- A static method belongs to the class rather than object of a class.
- A static method can be invoked without the need for creating an instance of a class.
- static method can access static data member and can change the value of it.

\

```
//Program of changing the common property of all objects(static field).    class Student9{       int rollno;       String name;       static String college = "ITS";              static void change(){       college = "BBDIT";       }         Student9(int r, String n){       rollno = r;       name = n;       }         void display (){System.out.println(rollno+" "+name+" "+college);}        public static void main(String args[]){      Student9.change();        Student9 s1 = new Student9 (111,"Karan");      Student9 s2 = new Student9 (222,"Aryan");      Student9 s3 = new Student9 (333,"Sonoo");        s1.display();      s2.display();      s3.display();      }  }  
```

\
**Output:**111 Karan BBDIT 222 Aryan BBDIT333 Sonoo BBDIT\

### Answer by Anonymous User

**The static keyword in java i**s used for memory management mainly. We can apply java static keyword with variables, methods, blocks and nested class. The static keyword belongs to the class than instance of the class. java static methods can be called without creating an object of class. Have we noticed why we write static keyword when defining main it's because program execution begins from main and no object has been created yet. Consider the example below of static methods.\

```
class programming {  public static void main(String[] args) {    display();  }   static void display() {    System.out.println("Java is my favorite programming language.");  }}
```

\


---

Original Source: https://www.mindstick.com/interview/2362/what-is-static-method-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
