01.What is an Operator?
In Java, an operator is a special symbol or keyword used to perform operations like add, sub, div, etc....
02.How many operator?
Type of operator:
- Assignment operators: = 02.Arithmetic operatord : +,-,*./,%
- Unary operators: ++ ----> Increment operator -- ---> Decrement operator int no =10; no ++ ---> Post increment ++ no ---> Pre increment
no -- --->Post decrement
---no---->Pre decrement
Equality and relational operators : ==, !=,<,>,<=,>=.
Conditional opearators : &&,||
&&=AND opearator
||=OR operator
Operator: Symbol
Operand: Value
03.What is a variable?
A variable is a named storage location in a program that holds a value, which can be changed during the execution of the program.
A variable is like a box with a label on it. You can put a value in the box, change it later, or read it when you need it.
A variable has:
Name (e.g., x, score, total)
Value (e.g., 10, "Hello", True)
Variables can hold different types of data (number, text, boolean, etc.)
The value can be changed or updated.
04.How many variable?
Types of variable :
1. Local Variable
2. Global variables or Fields
05.What is the Local Variable?
- Declared inside a method, constructor, or block.
- Scope: Only available within that method/block.
- Must be initialized before use.
- Not accessible outside the method.
06.What is the Global variables or Fields?
1.These are variables declared outside methods, but inside the class.
2.Instance(object) Variable (Non-static)
* Declared without static inside a class.
* Default value is set if not initialized.
07.What is the Static Variable (Class Variable)?
1.Declared with the static keyword.
2.Common for all objects of the class.
3.Can be accessed with ClassName. variableName.
Top comments (0)