Assigning The Variables
Definition : A variable must be given a value after it has been declared but before it is used in an expression. This can be achieve in two ways. They are :
1. By using an assignment statement.
2. By using a read statement.
➤ Assignment Statement :- A simple method of giving values to a variable is through the assignment statement as follows. Already we discussed about on the data type declaration in last post then we have assigning the variable to that data types.
Syntax:- variable name= value;
Here variable name represents the name of the type that specify location of the value in the memory. Value is used to store the value of the variable name. Some of the example are given below.
Example:- ID NO =100;
percentage = 80.1;
PI = 3.14;
grade = 'A';
we are also string assignment expressions as shown below a=b=c=0; .
➤ It is also possible to assign a value to a variable at the time of its declaration. This is taken the form:
Syntax:- Data type variable name = value;
Example:- int Id NO = 100;
float percentage = 80.1f;
double pi = 3.14;
char grade ='A';
The process of giving initial values to variables is known as the initialization values. The ones that are not initialization are automatically set to zero.
Fundamental Data-Types
In Computer science programming, a data type or type clarify the data which tells the computer or interpreters that how the programmer intends to use the data. A most of the programming languages support various type of data that will use for like example: Real, Integer or Boolean .
In previous post we have already discuss about on the data type and their types in the real industry. The below following are the Fundamental data types and their categories also memory sizes in Java .
Definition
Data types specify the size and type of values that can be stored in primary memory of a computer. The below diagram shows about that on data type and their types in java.
byte 1 byte
short 2 byte
➤ Integer Category int 4 byte
long 8 byte
float 4 byte
➤ Float
double 8 byte
➤ Character char 2 byte
➤ Boolean boolean 1 byte
➽Data types are classified into two types. They are :
1. Primitive data type
i . Numeric
a. Integer b. Floating point
ii. Non-Numeric
a. Character b. Boolean
2. Non-primitive data type
i. Classes
ii. Arrays
iii. Interfaces
➤ Integer :- Integer types can hold the whole numbers. Java supports fours types of integers, They are given below.
Type Size
Byte one byte
Short two byte
int four byte
long eight byte
➤ Floating point :- Floating point data type can hold the number with fractional parts. Java supports two types of data types.
Type Size
float four byte
double eight byte
➤ Character type :- Character data type is used to store the character constants in main memory. The memory size is two bytes.
➤ Boolean type :- Boolean type is used when we want to rest a particular conditions during the execution of the program. Either it must be true or false.
➤ Classes :- A class is a collection of methods and variables (or) A self contained block of statement's is called a class.
➤ Array :- An array is a group of related data items that share a common name.
➤ Interface :- It is a named called collection of methods definitions.
No comments:
Post a Comment
Thanks for visiting my site..