• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Instance and Class

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am new to Java Technology.Could anybody explain me what is the difference between instance and class.

Thanx in advance.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Class is a type like men is a class as me, you and millions on earth. They are of instance of class men. An instance have a physical existence like me sachin and u. But the class describes the behaviour of the instance. like all men have some common things like heavy voice, a beard etc.
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sun has a convenient online tutorial on basic object oriented concepts and java programming. HTH.
 
ppavya india
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by agSachin Agrawal:
Class is a type like men is a class as me, you and millions on earth. They are of instance of class men. An instance have a physical existence like me sachin and u. But the class describes the behaviour of the instance. like all men have some common things like heavy voice, a beard etc.

 
ppavya india
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by agSachin Agrawal:
Class is a type like men is a class as me, you and millions on earth. They are of instance of class men. An instance have a physical existence like me sachin and u. But the class describes the behaviour of the instance. like all men have some common things like heavy voice, a beard etc.



Thanx man, and looking your help in future also.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
Consider this, A class is an architectural design for a project. The instances are the actual concrete pieces that are then build based on this design. Apart from this please read the link to the tutorial given in the earlier post.

Hope it helps.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A class is a structural and functional description of an object.
An object is an actual existence (instance) of that class. Different instances can have different structural features, but they all carry out the same functions basically.

Hence when you want to create a Book, you first create a class Book which has a variable called author, nameOfBook, category.

class Book
{
String author, nameOfBook, category;
Book(String a, String n, String c)
{
author = a; nameOfBook=n; category=c;
}
}

And then you create different objects of this class, such as

Book b1 = new Book("Peter van der Linden", "Just Java 2", "Software");
Book b2 = new Book("Carl Segan", "Contact", "Science Fiction");

Thus each object will be structurally similar but can have a different state, but will exhibit similar behaviour, since they all belong to the same class.
 
ppavya india
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx all,
...got the diff. between instance and class. Ok. Now one more quetion whta is the diff. between instance methods and class methods, if possible explain me with the help of one example.
Thanx in advance.
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic