Computer Science, asked by mamtakumariraj, 8 months ago

write a program to display that concepts that we can assign new values to a variables, as many times as required during the execution of the program.


Please give right answer

I will Mark you as brainliest and follow you​

Answers

Answered by Skvkartik31
1

Answer:

Variables -- declaring and assigning values

Before discussing input and output, including System.out.println(...) which you used in Hello.java, it will be helpful to cover the topic of variables. You will have come across the idea of variables in mathematics, and the concept of a variable in programming is similar.

A variable is associated with space in the computer's memory that can hold a value (often a number). Each variable has a name, which you choose, and subsequently use to refer to it.

You must start by declaring the variable, this gives the variable a name and reserves some memory space to store whatever value the variable takes. It also tells the compiler what you intend the variable to represent. This is known as the variable's type. For example a variable which always takes integer values, can be declared as type int in Java. For example the line of code

int i;

declares an integer variable (i.e. a variable of type int) which we have chosen to call i. As an int, it can store any integer value between -2147483648 and 2147483647.

Java provides types to represent several kinds of number, e.g. integer and floating point, non-numerical things like text, and other more abstract things. These are listed on page [*]. You can give a variable a longer name if you like, and it is usually a good idea to choose a word that explains what the variable is for. The convention is for variables to be named using lower case letters, or if the name consists of more than one word, that a capital be used at the start of each word other than the first. You may also use numbers or an underscore _ in your variable names, but not at the beginning of the name. Examples of some well chosen and valid variable names might be total, maxValue, answer1.

Similar questions