answersLogoWhite

0

Yes, example:

(pixel is the object)

public static void brighten(int value) {

color += value;

System.out.println(color);

}

pixel.brighten(30);

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

How do you call static methods without using objects?

You can call a static method via an object; the other alternative is to use the class name. A common example is the following, to calculate the exponential function: Math.exp(x) Here, exp() is a static function in the class Math. Note that the class name is used instead of an object.


Static method can be call object?

yes we can call a static method with object


When should you use static method and when should we use instance method?

Non-static methods are the "normal" type of methods for a class to have. They use instance variables to perform certain actions. In other words, object A and object B of the same class may behave differently when we call one of their Non-static methods depending on the value of their instance variables. Static methods on the other hand behave the exact same way for all instances of a class. object A and B of the same class will act in the same way when we call one of their Static methods. (*NOTE* Static methods cannot use instance variables)


Why use static?

Static is a keyword which is used to call the methods or variables without creation of that class object. It will directly calls the respective method and varialbles.


How objets call from class in java?

if we are acessing static members we can call them directly,while coming to non static members inorder to call object we have to call by using new operator......


Is it possible to call static methods with out creating object?

Yes, we can access all methods which declare with static means then we can access.. ex: class s{ static method() { System.out.println("Welcome"); } } class fun{ public static void main(String args[]) { method(); } }


Static variable and static methods in java?

== == Static method cannot be overwritten because it belongs to the class and not to the ObjectIf you're asking about overriding or overloading, then yes. Static methods can be overridden and overloaded just like any other methods.


Can main method be non-static?

No, the reason is simple: A method marked as a static means, that you don't need create an instance (create an object with the 'new' operator) in order to use it. The main method is the entry point for a java application, therefor there is nothing after you call it. no one who can create an object of the type of your class and call the main method. So the jvm must call the main method with no object reference.


Will JVM execute static methods by default like static variables in java?

No. Static methods are invoked by using the name of the class instead of the name of an instance of a class. Example: public class Test { public static void methodA { // do something ... } public void methodB { // do something else ... } } A program could use methodA by simply calling it using the class name: // call the static method Test.methodA(); To use methodB(), a program would have to first create an instance of the class then call the method: // call the non-static method Test t = new Test(); t.methodB(); Note that you can call methodA from the instance: // call the static method Test t = new Test(); t.methodA(); However, this is considered bad practice. And you cannot call methodB at all using the class name: // can't do this - compile error Test.methodB();


Why main is static?

The main method is static because the JVM would be invoking this method as the starting point of execution. If this is like other normal methods, the JVM would have to instantiate an object of the class before it can call it. This is not possible because this is the starting point. If the main method is static the JVM can directly call this by specifying the class name.


What are the restriction on static functions in java?

Static Methods Can:Access only static variablesInvoke other static methods onlyStatic Methods cannot:Access Instance variablesInvoke instance or non-static methods


What do you call the movement of an electrical charge from one object to another?

static charge