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…
Example:
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.
Example:
Output:
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.
Example:
Output:
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.
Example:
Output:
Tamil average mark: 75
Java Tutorials
- Environment setup
- Basic concept
- Object Classes
- Constructors
- OOPS in java
- data abstraction
- Variable Types
- Modifiers
- Operators
- Loop Controls
- Decision Making
- Strings
- Arrays
- Date and Time
- Methods in java
Java sample assignments
Programming Topics
- Ada
- Assembly Language
- AutoCAD
- BASIC
- Computer virus
- C Programming
- Euphoria
- Fortran Homework Help
- Game programming language
- Java Assignment Help
- JavaScript
- Java Servlets Help
- Machine Language
- Matlab
- Pascal
- Perl
- PHP
- Python
- Ruby
- Servlet Life Cycle
- Smalltalk
- SOAP
- Visual Basic
- COBOL
- Lisp
- Logo Help
- Plankalkul Help
- Prolog
- REBOL
- Rexx
- Scheme Help
- TCL
- ToonTalk Help