Live chat


Java Variable types Homework Help

Java Variable types:

A variable is a container it holds the value. The variable must assign with data types. Depends on it holds the memory and value.

Variable declaration and initialization:

Data type variable = value , variable1 = value…


int x, y; // Declares two ints, x, y.

int x = 100, b = 20; // Example of initialization

float A = 12; // initializes a float type variable A.

char b = 'b'; // the char variable b is initialized with value 'b'

There are three categories of variables available in java.

1. Local variables

2. Instance variables

3. Static variables

Local variables:

It is declared inside method of the class. We cannot access it outside from the class. For the local variable we have to assign the value there is no default value.



age of person is : 5

Instance variable:

It is defined without keyword STATIC keyword. It is defined outside method declaration. These variables are created when object created and destroyed when object is destroyed.



name : mani

mark : 100.0

Static Variables:

It is declared with keyword STATIC. It is access by class name. It is initialized first only once. It is also known as class variable.



Tamil average mark: 75

Copyright © 2009-2023 UrgentHomework.com, All right reserved.