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 the term Multiprogramming system

    Define the term Multiprogramming system: It is an operating system which is able to run multiple programs parallel.

  • 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 : What is Big-endian Big-endian : This is

    Big-endian: This is a common difference among machines, the order in which they store individual bytes of multi-byte numerical data. Big-endian machine stores the higher-order bytes previous to the lower-order bytes.

  • Q : Explain Enumerated type Enumerated type

    Enumerated type: A data type-not directly accessible in Java - in which symbolic names are employed for a series of constant numeric values. They facilitate the evading of magic numbers. They can be simulated in the Java with fields i

  • Q : What is Carriage return Carriage return

    Carriage return: The \r character. It is also used as a synonym for the `Return' or `Enter' key employed to terminate a line of text and the name derives from the carriage on mechanical typewriter.

  • Q : Describe Last in-first out Last in,

    Last in, first out: It is the LIFO semantics of a stack data structure. Items are eliminated in the opposite order to which it arrived in the stack; therefore newer items are always eliminated before older ones.

  • Q : Define Absolute filename Absolute

    Absolute filename: It is a filename whose full path is unambiguously provided starting from the top (that is, root) of a file system tree. For example: c:\Java\bin\javac.exe

  • Q : Define several features of XQuery

    Define several features of XQuery?

  • Q : Explain the term Portable Portable :

    Portable: The Portability is the quality of a program which makes it probable to run it on different kinds of computers. The programs written in low level languages are usually not very portable since they are generally closely tied to a particular in

©TutorsGlobe All rights reserved 2022-2023.