answersLogoWhite

0


Best Answer

Yes. In Java methods can be static and synchronized.

Static methods access other static members in the class.

Static in case of inheritance are treated as non - static.

Synchronized methods are those which have dedicated thread attached to it and no other can access until currrent thread leaves the control from it.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can a method be static and synchronized?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the synchronized methods and synchronized statements in java?

Synchronized Methods are methods that have the keyword synchronized in the method signature. Synchronized statements are pieces of java code that are surrounded by brackets which have the keyword synchronized qualifying them. Both cases mean that - only one thread will be able to access the method or the statement that is synchronized


Can you refer static method from non static method in java?

Yes, it is possible to call a static method from a non-static method. However, it is not possible to call a non-static method from a static method without first having an instance to operate on.


Can static method can be overloaded or not?

Yes, a static method may be overloaded.


Tell about static method?

in java a method is said to be static if 'static 'keyword is used before the method name . foe ex.- static void show(){ ........ } this method has the following property-- 1. it can invoke only a static method. 2. it can't be reffered using keyword 'this','super'. 3.static method can access only a STATIC MEMBER VARIABLE or STATIC CLASS VARIABLE . 4. there should not be static & non static version of a nethod in a class . 5.static method can be used before the creation of d object of dt class.


Why you use main method when you can use static method?

The main method is called by the jvm when your program is executed. The main method is a static method: public static void main(String[] args) {} A static method is method that can be run without instantiate the class (creating an object from it) The main method is a static method. No other static method could replace it's functionality. PS By static method do you mean static initialiser? I often use static initialisers instead of a main method, but in these cases you must still have a main method, albeit an empty one ie. public static void main(String[] args) {} Notice that the method has an empty body A main method must be used if you intend to accept parameters at run time from the jvm.


Static method can be call object?

yes we can call a static method with object


Can you refer non static method from static content in java?

Shortly, you can not.Different approaches are however available.1. Put your non static method in different class. Then call it from your static content by first instantiating the class.2. Make a duplicate static method for your non static method and use from your static content.


What is need of static method?

If you need to access a method without creating an object of corresponding class, it need to be a static method.


Which keyword when applied on a method indicates that only one thread should execute the method at a time?

synchronized


Do static methods operate on objects why?

No. Why? By definition. A static method is, precisely, a method that is not meant to operate on an object. It can only work with static fields, and other static methods, of its class.


Can static variable be used inside a static method?

Yes.


Is mode is rigidly defined method?

A static method