DEV Community

Nanthini Ammu
Nanthini Ammu

Posted on

Class and Objects

Class:

  1. Class is a Template or BluePrint or set of instructions to build a specific type of object.
  2. Class doesn't hold any memory.
  3. Class is a Logical Entity.
  4. Class in java determines how an object will behave and what the object will contain.
  5. Class names must begin with a letter, the dollar sign ($), or an underscore character (_). They cannot start with a digit.
  6. Source file name must exactly match the class name.
  7. Class names should be written in PascalCase (also known as UpperCamelCase). The first letter of the class name and the first letter of each subsequent internal word should be capitalized(Ex: MyClassName).
  8. Name can contain numbers only in the middle and at the end.
  9. Java is case-sensitive, so MyClassName and myclassname are treated as two different names.

Object:

  1. Object is a Physical Entity or Real-time Entity.
  2. Object represents Class.
  3. Object is memory reference of a class.
  4. Object is a member of a class.
  5. Object is an instance of a class.
  6. Object is combination of state and behaviours.
  7. The state of an object is stored in a field or variable.
  8. The behaviour of an object is defined by methods.
  9. Objects are created at runtime from templates, which are also know as classes.
  10. Object name should follow lowercamelcase.(Ex: className)

Data Types:

Primitive Data Types:

  1. byte - 1 byte - Stores whole numbers from -128 to 127.
  2. short - 2 bytes - Stores whole numbers from -32,768 to 32,767.
  3. int - 4 bytes - Stores whole numbers from -2,147,483,648 to 2,147,483,647.
  4. long - 8 bytes - Stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
  5. float - 4 bytes - Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits.
  6. double - 8 bytes - Stores fractional numbers. Sufficient for storing 15 decimal digits.
  7. boolean - 1 bit - Stores true or false values.
  8. char - 2 bytes - Stores a single character.

Non Primitive Data Type:
String - It is used to store text(set of characters). It is an object of a class Syring.

Top comments (0)