classes and objects

Class:
A class is a blue print of Member variable's and Member methods,The class has a mainly two access specifiers those are listed bellow.
default:
          used to access methods with in the same class.
public:
         used to access methods from any package.

Example:
class MyClass{
     int a,b;
     public void myMethod(){
     }
     .....................................
     .....................................
 }

Object:

An object is nothing but a state and behaviour of the class,there three steps to create an object listed bellow

  • Declaration
  • Instantiation
  • Initialization

   Example

   MyClass object = new MyClass();

No comments:

Post a Comment