• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

obiect/class/method

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want o know the difference between CLASS/OBJECT and METHOD in java.
Please explain in simple words.
 
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A class is a container of variables and methods. A class should contain methods and variables which are related in some way. A method is a specific task or job which gets performed on a class.
An example might be a bank class. If you wanted to represent a bank as a class you would have variables and methods which have something to do with banking. So methods might be: depositMoney, withdrawMoney, and a variable might be currentBalance.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Class is a definition of a type of object and a place to store things that are valid across all objects of the Class (static variables).
An object of the Class is an instance of of something created from that definition.
Member variables (also known as instance variables) are places to store the STATE of the object at any given time.
Methods are written in the Class and define the BEHAVIOR of an object. You know - things that it can DO with instructions (code) on how to get it done.
Local variables (created inside methods or blocks) are temporary working variables that are disposed of as soon as the block or method is complete.

[This message has been edited by Cindy Glass (edited October 28, 2001).]
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Abdul Rahim1972,
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at "JavaRanch Naming Policy" . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. We would like this forum to be as Professional as possible. Please choose a new name which meets the requirements.
Thanks,
Cindy
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think of a class as a cookie cutter. With a class (that contains fields and methods) you can create as many objects of that type class as you want to.
 
reply
    Bookmark Topic Watch Topic
  • New Topic