--%>

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 : Explain Out-of-bounds value

    Out-of-bounds value: It is a redundant value employed to point out that a different action from the norm is needed at some point. The read technique of InputStream returns -1 to point out that the end of a stream has been reached, for illustration, ra

  • Q : Explain a way to install JAVA S60 device

    What should I do when installation fails whilst trying to install a Java™ Verified application to a certain S60 device?

  • Q : Reads a line of text and tests whether

    palindrome.asm -- reads a line of text and tests whether it is a palindrome. ## Register usage: ## $t1 - A. ## $t2 - B. ## $t3 - the character *A. ## $t4 - the character *B. ## $v0 - syscall parameter / return values. ## $a0 - s

  • Q : What are the valid and invalid XHTML

    What are the valid and invalid XHTML element names?

  • Q : Web based programming homework

    Component 2 Task b: Task Description Computing students at this University who study on undergraduate courses require a method to view their module marks and to see how they are progressing on the module. You have been asked to develop a web

  • Q : Intermediate language concept Describe

    Describe the term Intermediate language? Illustrate in brief.

  • Q : Define Protocol Protocol : It is a set

    Protocol: It is a set of rules for interaction between two processes. The protocol is generally specified in a Uniform Resource Locator (abbreviated as URL) to point out how a specific resource must be transferred from a Web server to the requesting c

  • Q : Define Short-circuit operator

    Short-circuit operator: It is an operator in which only as a lot of operands are computed as are required to determine the final outcome of the operation. The logical-and (&&) and logical-or (||) operators are most general illustration, though

  • Q : Write a program to print out ten random

    Write a program to print out ten random numbers from the following sets: a) {0, 1, 2, 3, 4, 5, ...99, 100} b) {1, 2, 3, 4, 5, 6} c) (10, 20, 30, 40, 50,...990, 1000} d) {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5} e) {1.5, 2.0, 2.5, 3.0, 3.5}  

  • Q : Class and Object and explain diverse

    Q. Define class and object with example and explain diverse specifies.