Docsity

College Presentation Speach Variable in Java, Schemes and Mind Maps of Computer science

Toggle sidebar
bg1
Explanation Speech: Variables in Java
Based on the uploaded PowerPoint: “Variable in Java”
Slide 1 — Title: “Variables in Java”
Good morning everyone.
Today I am going to present a very important basic concept of Java
programming, which is Variables in Java.
Variables are one of the first concepts that we need to understand when
learning Java, because variables allow a program to store information and
use that information while the program is running.
Slide 2 — What is a Variable?
The example is:
int age = 20;
Let us understand every part of this statement.
int means integer. It tells Java that the variable will contain a whole number,
such as 10, 20, 85, or 100.
age is the name of the variable. We give a variable a meaningful name so
that we can easily understand what information it contains.
The symbol = is called the assignment operator. It means: put the value on
the right side into the variable on the left side.
20 is the value stored in the variable.
The semicolon ; tells Java that the statement has ended.
Therefore, int age = 20; means: create an integer variable called age and
store the value 20 in it.
Speaking version:
A variable is a named location in computer memory used to store a value.
The value can change while the program is running. For example, int age =
20;. Here, int is the data type, age is the variable name, the equal sign is the
assignment operator, and 20 is the value. The semicolon indicates the end of
the statement.
Slide 3 — Why Are Variables Important?
Example:
int marks = 85;
pf3
pf4
pf5

Partial preview of the text

Download College Presentation Speach Variable in Java and more Schemes and Mind Maps Computer science in PDF only on Docsity!

Explanation Speech: Variables in Java

Based on the uploaded PowerPoint: “Variable in Java”

Slide 1 — Title: “Variables in Java”

Good morning everyone. Today I am going to present a very important basic concept of Java programming, which is Variables in Java. Variables are one of the first concepts that we need to understand when learning Java, because variables allow a program to store information and use that information while the program is running.

Slide 2 — What is a Variable?

The example is: int age = 20; Let us understand every part of this statement. int means integer. It tells Java that the variable will contain a whole number, such as 10, 20, 85, or 100. age is the name of the variable. We give a variable a meaningful name so that we can easily understand what information it contains. The symbol = is called the assignment operator. It means: put the value on the right side into the variable on the left side. 20 is the value stored in the variable. The semicolon ; tells Java that the statement has ended. Therefore, int age = 20; means: create an integer variable called age and store the value 20 in it. Speaking version: A variable is a named location in computer memory used to store a value. The value can change while the program is running. For example, int age = 20;. Here, int is the data type, age is the variable name, the equal sign is the assignment operator, and 20 is the value. The semicolon indicates the end of the statement.

Slide 3 — Why Are Variables Important?

Example: int marks = 85;

int is the data type. marks is the variable name. = is the assignment operator. 85 is the value assigned to marks. ; indicates the end of the statement. Speaking version: Variables are important because programs need to store information. For example, if we are developing a student management system, we may need to store a student's marks. We can write int marks = 85;. Here, marks stores the student's marks. The program can access this value whenever it needs to calculate or display the student's result.

Slide 4 — Declaration of a Variable

Example: int age; int is the data type. age is the variable name. ; ends the statement. Notice that there is no value after the variable name. We have only declared the variable. int age; means: Java, create a variable named age that is intended to store an integer. Speaking version: Declaration means introducing a variable to Java by specifying its data type and its name. For example, int age;. Here, int specifies the type of data and age is the name of the variable. At this point, we are declaring the variable; we are not assigning an initial value in this statement.

Slide 5 — Initialization of a Variable

Example: int age = 20; int is the data type. age is the variable name. = is the assignment operator. 20 is the initial value. ; indicates the end of the statement.

[] indicates an array. String[] means an array of String values. args is the name of the parameter. It is commonly used for command-line arguments. { indicates the beginning of the method body. int age = 20; creates a local variable called age and gives it the value 20. } indicates the end of the method body. Speaking version: This example shows a local variable. The variable age is declared inside the main() method. Therefore, it is a local variable. The important point is that a local variable can be used only within the method, constructor, or block where it has been declared.

Slide 8 — Instance and Static Variables

The example is: class Student { String name; static String college = "ABC"; } Let us explain it carefully. class is a Java keyword used to define a class. Student is the name of the class. { starts the class body. String name; means String is the data type and name is the variable name. Because name is declared inside the class but is not static, it is an instance variable. Each Student object can have its own name. static String college = "ABC"; static indicates that the variable belongs to the class rather than separately belonging to every object. String is the data type. college is the variable name. = is the assignment operator. "ABC" is a String value. The double quotation marks indicate text. ; ends the statement.

Speaking version: In this example, name is an instance variable because each Student object can have its own name. On the other hand, college is a static variable. Because it is static, it belongs to the class and can be shared by all Student objects. This distinction is very important when we work with Java classes and objects.

Slide 9 — Common Data Types

The examples are: int age = 20; double price = 99.5; char grade = 'A'; boolean passed = true; String name = "Ahmed"; Example 1: int age = 20; int is a whole-number data type. age is the variable name. = is the assignment operator. 20 is the integer value. ; ends the statement. Example 2: double price = 99.5; double is used for decimal numbers. price is the variable name. 99.5 is the decimal value. Example 3: char grade = 'A'; char means a single character. grade is the variable name. 'A' is the character A. Notice the difference: 'A' uses single quotation marks because it represents a character. "Ahmed" uses double quotation marks because it represents a String. Example 4: boolean passed = true;