Classes and Objects in Java full explanation

Classes and Objects are basic concepts of Object Oriented Programming which revolve around the real life entities.

Class is a collection of data member and member function is called as Class.

Object is run time entity.


Classes in Java: 
A class may be a user outlined blueprint or epitome from that objects ar created.  It represents the set of properties or ways that ar common to all or any objects of 1 kind. In general, category declarations will embody these parts, in order:

  • Modifiers : a category will be public or has default access (Refer this for details).
  • Class name: The name ought to begin with a initial letter (capitalized by convention).
  • Superclass(if any): The name of the class’s parent (superclass), if any, preceded by the keyword extends. a category will solely extend (subclass) one parent.
  • Interfaces(if any): A comma-separated list of interfaces enforced by the category, if any, preceded by the keyword implements. a category will implement quite one interface.
  • Body: the category body encircled by Curly braces {}.

Objects in Java:
it is a basic unit of Object orienting Programming and represents the $64000 life entities.  A typical Java program creates several objects, that as you recognize, move by invoking ways. Associate in Nursing object consists of :

  • State : it's drawn by attributes of Associate in Nursing object. It additionally reflects the properties of Associate in Nursing object.
  • Behavior : it's drawn by ways of Associate in Nursing object. It additionally reflects the response of Associate in Nursing object with different objects.
  • Identity : It provides a novel name to Associate in Nursing object and permits one object to move with different objects.