12.1 Class

By | March 25, 2022

A class is a group of objects which have common properties. It is a template or blueprint from which objects are created. It is a logical entity. It can’t be physical.

A class in Java can contain:

  • Fields
  • Methods
  • Constructors
  • Blocks
  • Nested class and interface
Class in Java

Syntax to declare a class:

class <class_name>{  
    field;  
    method;  
}  

Leave a Reply

Your email address will not be published. Required fields are marked *