Wednesday, 18 March 2015

Q. what is identifier in java?



Ans: Any name in java is called an identfier in java.It may be a method name,class name,variable name etc.

 The allowed characters in identifier are :

1. Alphabets a to z both upper and lower case.

2.Digits 0-9

3.$ and _

e.g- Customer_name, _$Car,_Car etc..


If we are using other then these we will get a compillation error.

  • Identifier cannot start with digits.

          e.g- 123total          // compillation error


  • java identifiers are case sensitive.

         e.g- student and Student are different.

  • Reserved words cannot be used as identifiers.

  • All predefined java class name and interface name we can use as identifier but not recommendable. 

e.g-  class TestIdentifier

      {

            int String=25;       // OK

            System.out.println(String);

       }


No comments:

Post a Comment