State two rules you should follow for naming a class

Question :

State two rules you should follow for naming a class

While using names for a class the following set of rules are to be kept in mind.

1. It can have any alphabet (capital or small), digits, underscore and dollar sign characters. For example, a, b, cat, mat123, cost_price, Topaz$ are all example of valid identifier.

2. It should not begin with digits or should not contain any special character. For example 2ab, ab#c, top@, etc., are invalid identifiers as it either begins with a digit or contain special characters (like #, @).

3. It cannot have a space between it. For example, Simple Interest or Selling Price are invalid class-names as it contains a space.

4. It must not be a keyword. For example, for, while, do are invalid class-names as they are keywords and are assigned some special function for the language.

5. It can be of any length. Even though Java gives you the flexibility to provide a huge length for an identifier a very long name is impractical and difficult to manage.


Similar Questions


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz