course content

Course Content

Introduction to Java



A variable is a piece of data that has a name and value. It stores information that can be used later in a program. Variables are declared before they are used. It tells the compiler what kind of data the variable will hold and how much memory to set aside for it.

The syntax for variable declaration is:


If variables are of the same type, they are separated by commas ,.


Initializing variables

Initializing variables is a process of assigning values to them. This process of initialization can be done in two ways:

1. We call it an assignment statement by assigning a value to the variable after it has been declared.

The syntax of the assignment statement is:


2. By assigning a value to the variable at the time of declaration - we call it an initializer.


You can make the above two steps into one step.



Which is the right way to define a char variable in Java? Select all correct answers.

Select the correct answer

Section 1.

Chapter 6