Explain class vs. instance with example using java

Explain class vs. instance with example using java.

A class is a program construct which encapsulates data and operations on data. It is a blue print of an object.

An object can be called as an ‘instance’ of a class.

The variables and methods (without static key word) that are declared in the class, but not in the methods are called as instance variables which have one copy per object. Once an object is created, it is said that, an instance of the class is created.

Class variables and methods occur once per class where as the instance variables and methods occur once per instance of a class (per object).
What is a method?
What is a method? - A java method is a set of statements to perform a task. A method is placed in a class.Signatures of methods...
Difference between instance variable and a class variable
Difference between instance variable and a class variable - An instance variable is a variable which has one copy per object / instance. That means every object....
Explain how to create instance of a class
Explain how to create instance of a class - Java supports 3 ways of creating instances - By using new operator – Ex : Product prodMouse = new Product();....
Post your comment
Discussion Board
java
its vry boring sbjct
choko 04-23-2012