Online Examination System for all learner!!! coming soon..

Showing posts with label data type in java. Show all posts
Showing posts with label data type in java. Show all posts

JAVA : Data Type

Integers:

It includes whole valued signed numbers which are as follow.

Byte- Whose width is 8 and it ranges from -128 to 127. It is the smallest integer type. It is useful  when user is dealing with stream or flowing data from a network or a file.
Declaration of two byte variables called x and y is as follow
Byte x, y;

Short- The width of this type of integer is 16 and it ranges from -32,768 to 32,767. It is the least commonly used data type in java.
Declaration:
Short a;
Short b;

Int- The width of this type of integer is 32 and it ranges from -2,147,483,648 to 2,147,483,647. It is more efficient as compared to byte and short. It is commonly used to control loops and indexed arrays.

Declaration:
Int a;

Long-  The width of this type of integer is 64 and it ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. This is used for those values which are large enough that the integer cannot handle them.
Declaration:
Int light speed;
Long days;
Long second;
Seconds = days *24 *60*60;

Floating point type:

This is for real numbers used for calculation such as square roots, sine and cosine. These are of two types.

Float- Width in bits is 32 and range is from 1.4e-045 to 3.4e + 038. Float is used as a variable type for the fractional component, but specifies single precision. It can be used in representing dollars and cents.
Declaration:
Float hightemp;

Double- Width in bits is 64 and range is from 4.9e-324 to 1.8e + 308.it is used and is optimized in such a way that I can be used for high speed mathematic calculation. It has double precision which is faster than the single precision. Function such as sin()and sqrt() etc, return double values.
Declaration:
Double pi, r, a;
r = 10.4;
pi = 3.14;
a = pi* r * r;

Characters:

  • The data type used store or declare character in java is char.
  • It is 16-bit type in java. Range of a char is 0 to 65,536.
  • There are no chars which are negative in nature.
Program demonstration for char
Class charExample
{
Public static void main (String args []) {
Char a, b;
a=88;
b=’y’;
system.out.print (“a and b: “);
system.out.println (a + “ “ +b);
}
}

Booleans:

  • It is a primitive type for logical values.
  • This tends have only one of two possible values, true or false.
  • It is governed by if or for control state
  <<Previous Page                     Download PDF                    Next Page>> 

C Programming Online Test 1

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answ...