English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

in programming

2007-06-26 20:48:09 · 8 answers · asked by Bhavani 1 in Computers & Internet Programming & Design

8 answers

Quite a bit my friend.

A class is a block of code that encompasses many variables, structures, enumerations, methods and much more. Classes hold the biggest chunk of data. A practical example of a class would be a car engine. The car engine could have many properties (variables) and methods (functions). For example, it's variables could tell us how hot it is, or how hard it's working. Additionally it's functions can be to start up, or to generate work.

A method is an object-oriented term for function. It performs whatever the developer defined before they compiled it. A method could have many parameters and/or a return value. A practical example of that is like a copy machine that has papers as parameters and copied paper as the output return value.

2007-06-26 20:57:04 · answer #1 · answered by xytose 3 · 5 0

Difference Between Class And Method

2017-01-19 15:23:13 · answer #2 · answered by Anonymous · 0 0

A class is a set of objects that share a common structure and a common behavior; a single object is simply an instance of a class . A class is a specification of structure (instance variables),behavior(methods) and inheritance for objects.

Classes are important mechanism for classifying objects.The chief role of a class is to define the properties and procedures (state and behavior) and applicability of its instances.

A method or behavior of an object is defined by its class and typically can access the internal state of an object of the class to perform some operation.Methods encapsulate the behavior of the object,provide interface to the object and hide any of the internal structure and states maintained by the object.

As we know objects communicate by sending messages this is where the methods and functions differ.In a language like C or BASIC suppose we have to calculate the area of a circle .The subroutines will just call the function areaofcircle() by name and the parameters will be passed and the result will be obtained.

While in object oriented approach we instead of calling it by name will pass a message. The message will be sent by the main class to the more general method say area here and then from there to the more like triangle , rectangle , circle etc.
This is where the difference is between function and method.

2007-06-26 20:53:39 · answer #3 · answered by rohit k 2 · 0 0

Here goes, as much for my benefit as anyone else's and this is designed to be imperfect but explanatory to people like me who have been confused for years.

Method: the "how to" for straightforward, repeatable programming code, like function or procedure, can be included in many Classes (think "programs") and can be passed info (parameters) and passes back info (return)

Example: 1. read_from_database(table name), 2.Write_to_database(table name), 3.Get_user_input_form

Class: a program (or template, they call it) that has its own code, variables, defaults, forms, arrays, etc., and may optionally include one or many Methods

Example: "subscribe, unsubscribe from distribution list"

Object: think of this as an instance or instantiation of the Class. Suddenly the "template" is real and its variables are populated.
---

Examples:

Methods:
show_Form
get username
get password
show banner
read from database
get user input
write to database

Class:
"subscribe, unsubscribe from distribution list"; which contains all the "glue" that holds and coordinates all the Methods" So far we're working on paper and screen, nothing is running yet and all we have created is a “template”.

Object:
Now we invoke the Object i.e. run the program or Class, and all the variables get populated and defaults default, and it is no longer a template, whether you're desk checking it by running through I/O examples or actually running the program.

This would explain why Class and Object tend to be used interchangeably, much as "database" and "instance" are used interchangeably, however the one (database) is shut down and the other (instance) is running version of the database, with memory allocated and so on.

In my mind, Class is the non-running, template or program, whereas Object would be the Class, alive and running with all its variables populated or defaulted, etc. Subtle difference.

I know there is more to it, but how far off the basics am I?

2014-01-03 03:04:46 · answer #4 · answered by Anonymous · 1 0

If you are familier with progrmming terms.. here it is..

A Method - Is just like a function() in other Programming langauge.

A Class - Basically is a Object. The object contains group of methods and attributes through which you can access the object.

Example : Receiptionist is a Class

The Methods are - receivePeople()
provideInformationToPeople()
attendPhoneCalls()

Hope this givesyou idea.. Please update me if it is ok

2007-06-26 21:03:41 · answer #5 · answered by Venkat K 2 · 4 0

if i remember correctly, classes are like pre-packaged modules complete with unique functions and variables only it could use. Any instance of a class could use the unique functions and variables it was provided with the "parent" class. For example, think of a class named "student". It has variables name, address, telephone number, strengths, weaknesses. Then, an invocation of class "student" occurred called, "John". class "John" will also have the same variables and methods which are unique to class "student", the parent class. A method on the other hand is similar to a function in C. It could be used by any other class or method and it has no unique properties.

2007-06-26 21:01:37 · answer #6 · answered by triamburate 2 · 0 0

a method is the interface of a class, describing how you can use the class.
a class contains methods and attributes.

2007-06-26 20:52:25 · answer #7 · answered by A117 1 · 1 0

thanks

2015-06-14 20:28:40 · answer #8 · answered by shennalyn 1 · 0 0

fedest.com, questions and answers