should static methods have same result for every object?

Go To StackoverFlow.com

-4

I have a very simple yes no question: should static methods have same result for every object?

2012-04-04 17:41
by F M
The questions phrasing makes it difficult to answer correctly - Johan Sjöberg 2012-04-04 17:43
why minuse...?!?! - F M 2012-04-04 17:57
@ForoughMehralian - see this article on writing good questions, and this meta post if English isn't your first language - Paul Bellora 2012-04-04 18:15
I meant that I want to know do the static functions have the same result on every object as we know we can call the function by the class name (with out making object) or in other words is this a property of static functions - F M 2012-05-05 05:45


6

No

public static boolean isEven(int number){
    return (number %2 ==0);    
}
2012-04-04 17:41
by Jigar Joshi
why the downvote :) , care to comment, Frustration of question shouldn't be released on answers : - Jigar Joshi 2012-04-04 17:42
Yeah, I'm kinda curious too... the question very clearly states it's a "yes/no" question. Very simple questions get very simple responses. If you wanted something different, then you're asking the wrong question.. - CodeBlind 2012-04-04 17:44
as upvoter who got downvoted w/o reasons (to me) in the past, and tried complaining and found high-reputation guys telling me it's pointless and silly to pretend and require downvoters to explain (and in fact a system to force downvoters to comment does not exist and won't, for retaliation fears too), I can explain my upvote: simple logical direct answer to a yes/no question... : - ShinTakezou 2012-04-04 17:47


3

What do you mean? Static methods can't have a this object, but they might return different results if they're passed different arguments. In other words, a.staticMethod and b.staticMethod will certainly return the same results, but staticMethod(a) and staticMethod(b) could differ.

2012-04-04 17:41
by Louis Wasserman
Could the downvoter explain? It's generally rude to downvote without explaining why you don't like the answer - Louis Wasserman 2012-04-04 17:42
I didn't downvote you but ... you start your "answer" with a question to the OP asking what they mean, then proceed to post ... something ... that may or may not have anything to do with the badly asked question. I have no idea what the OP is going on about, my ESP is on the fritz - Brian Roach 2012-04-04 17:46
I answered the only two interpretations of the OP's question I could think of, which seemed reasonable, given that the OP's question is notably unclear - Louis Wasserman 2012-04-04 17:47
Ads