--%>

Explain different types of variable iv java and also JVM

The kind of value that a variable can own is known as data type. When we state a variable we require specifying the type of value it will own with the name of the variable. This tells the compiler that the particular variable will hold the certain amount of the memory to store values. For example, in the lines of code above num is Int type and takes two bytes to hold the integer value, boils a Boolean value. Some common types of data are used in the java called as the primitive types like called bool, characters integers, floating point numbers (float and double) etc. These primitive data types are given below where size represents the memory size it takes, for example, Boolean takes a value true or false in 1 bit memory. It takes value false if not initialized (in the case of non local variables)

 

Java primitive data types

Data type

Description

size

Default value

Boolean

True or false

1 bit

False

Char

Unicode char

16 bit

\u 0000

Byte

Signed integer

8 bit

(byte) 0

Short

Signed

integer

 

16 bit

(short) 0

Int

Signed

integer

 

32 bit

0 l

Long

Signed

integer

 

64 bit

0.0 f

Float

Real number

32 bit

0

Double

Real number

64 bit

0.0 d

The java contains the follows types of variables:

1.      Instance variables (non static fields): in object oriented programming, objects store their individual states in the non static fields that is declared without the without the static keyword. Every object of the class has its own set of values for these non static variables so we can state that these are connected to objects (instances of the class). Hence these variables are also known as instance variable. These variables put default values if not initialized.

2.      Class variables (static fields): these are jointly linked to a class and none of the object can argue them its only proprietor. The variables defined with static an keyword are shared by all objects. Here objects to do not share store an individual value but they are forced to share it among themselves. These variables are confirmed as static fields with the use of static keyword. Always the similar set of values is shared between distinct objects of the identical class. So these variables are like global variables which are the same for all objects of the class. These variables put default values if not started.

3.      Local variables: the variables defined in a method or block of code is known as local variables. These variables can be accessed within a method or block of code only. These variables can be accessed within a method or techniques do not take default values if not or block of code only. These variables put default values if not started.

4.      Parameters: the variables defined in a method or block of code is known as local variables.

   Related Questions in Programming Languages

  • Q : Define Heap Abstractions Heap

    Heap Abstractions: The class abstractions that we discussed above are obtained by abstracting each field of base type. The number of instances of that particular class still needs to be bounded; this results in an under-approximation that is still use

  • Q : Define Continuous simulation Continuous

    Continuous simulation: In a continuous simulation, the time ticks past at a regular rate which is applicable to the specific simulation scenario. At each and every tick, all the objects in the simulation are informed of the passage of time and updated

  • Q : Security Manager on Applets Write down

    Write down some of the restrictions imposed by using a Security Manager on Applets?

  • Q : Define the term Internet Define the

    Define the term Internet: It is a global network of numerous interconnected networks.

  • Q : What is an Instantiation What is an

    What is an Instantiation: It is a creation of an instance of a class, i.e., an object.

  • Q : Tower of Hanoi Puzzle program using C#

    here I attached the assignment and examples of how can you do this assignments. I will post others in the next week as well.

  • Q : File handling modes and corresponding

    Q : Define the term Stack trace Define the

    Define the term Stack trace: It is a display of the runtime stack.

  • Q : Explain Edit-compile-run cycle

    Edit-compile-run cycle: A common portion of the program development procedure. The source file is made initially and compiled. The syntax errors should be corrected in the editor before compiling it again. Once the program has been productively compil

  • Q : Explain Sign extension Sign extension :

    Sign extension: Whenever an integer value from a type with a specific range is stored in a variable with a larger range, Java employs sign extension to determine the resultant value. The most important bit in the original value is employed to fill the