Naming Conventions and Data types.

 

Naming Conventions and Data types.

There are certain rules that should be followed to name Java variables, classes and objects A program will raise an error if these rules are not followed.

 Some of these rules are:

1.The name should not contain any embedded space or symbol, such as ?, !, @, #, %, &, {}, [], ",and /.
2. Name must be unique.
3. Name must begin with a letter, an underscore(_), or the dollar symbol($), or it must begin with alphabet that can be followed by sequence of letters or digits(0-9), '$', or '_'.
4. Name should not consist of a keyword.

Keyword:

Keywords are the reserved words with a special meaning for the language, Which express the language features. Keywords can not be used to define variables or classes. Java is a case sensitive language, and the keywords should be written in lowercase only.

The following table lists the Java keyword:

abstract
case
catch
const
double
finally
if
else
int
new
public
this
try and many more 


Data types: 

Data types are the classification or categorization of data items. Data types represent a kind of value which determines what operations can be performed on that data. Numeric, non-numeric and Boolean (true/false) data are the most used data types. However, each programming language has its own classification largely reflecting its programming philosophy.

There are 8 primitive data types in Java Programming Language:

Integer Type:

Int data type can store integer values. The four integer data types are:

  • byte
  • short
  • int
  • long


Floating Point Data type:

  • float
  • double



Boolean Type:

Can store only the values true and false.

Character Type:

Can store a single character, such as a symbol, letter and number. In the character type, there is one data type, char , 2 bytes of memory is allocated. 

Post a Comment

0 Comments