Sunday, 24 April 2011

Defining Classes

Defining  Classes

The  basic  structure   of   defining   a   class   is   as   follows :

scope   class   className [extends  class]
{
//class   implementation  statements 
}

When   declaring   the  scope  of  the  class  ,  we  have  several   options  to   control  how  other   classes   can   access  this  class:

public  ---   the  class   can  be  used  by  code   outside   of   the   file .  only  one  class   in  a  file   may   have   this  scope  .  The   file  must   be  named   with   the  class   name  followed   by   the   four-letter   .java    extension.

private  --- the   class  can  only  be   used  by   itself   and   must   be   subclassed  .

No comments: