Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
What is the difference between a class and a method in Java?
7 Answers
- peteamsLv 71 decade agoFavorite Answer
A class represents a type of thing, so Dog is an example class. A method represents an action on a class, so Speak is an example method.
You may have several classes related by an "is a" relationship. So there may be an Animal class together with a Dog class that "is a" Animal and a Cat class that "is a" Animal.
If Animal has a Speak method, then if you have an instance of a Dog or a Cat class you can ask it to Speak. Further you may supply different Speak methods for the two classes, so a Dog goes Woof! and a Cat goes Meow!
- ʃοχειλLv 71 decade ago
Well, I wish you not to leave this page to read any article before you have a clear mind about the difference. Their difference is much like the difference of being a human (the class) and speaking (something all human presumably do).
A method is a function commonly belonging to all the objects of a class; some operation which could be performed by all the instances (objects) of a class.
- ?Lv 44 years ago
An precis type is a form the has unimplemented strategies that could desire to be applied in a derived type. precis training won't be able to be instantiated. An interface isn't a form: "interface type" does no longer advise something. An interface specifies a series of strategies a form making use of it -- referred to as enforcing in Java -- will define. An interface is a settlement between the class and the shopper specifying a minimum set of strategies it implements. for added information, Google is your chum. HTH
- How do you think about the answers? You can sign in to vote the answer.
- JA12Lv 71 decade ago
The same as in any other "language"
A class is a collection of one or more methods and properties.
A method is a collection of properties.
- Anonymous1 decade ago
Think that human is a class and Steve is an object derived from the human class.
class human {
}
human Steve = new human();
Think that, human can walk, talk and eat. These are methods. Let's rewrite the human class as
class human {
void walk(){
System.out.println("I am walking");
}
void talk(){
System.out.println("I am talking");
}
void eat(){
System.out.println("I am eating");
}
}
human Steve = new human();
so Steve can walk, talk and eat. These are methods.
- 1 decade ago
This article will be helpful for you: http://www.codestyle.org/java/faq-Objects.shtml
Source(s): http://www.komplus.com.ua/