Java Programs On Operators, Arithmetic Promotion, Method Calling
Java Programs On Operators, Arithmetic Promotion, Method Calling
1
Aim: Programs on Operators, Arithmetic Promotion, Method Calling.
Theory:
Operators in Java
Operator in Java is a symbol that is used to perform operations. For example: +, -, *, / etc.
There are many types of operators in Java which are given below:
o Unary Operator,
o Arithmetic Operator,
o Shift Operator,
o Relational Operator,
o Bitwise Operator,
o Logical Operator,
o Ternary Operator and
o Assignment Operator.
Output:
10
12
12
10
-------------------------------------------------------------------------------------------------------------
Output:
15
5
50
2
0
-------------------------------------------------------------------------------------------------------------
It is widely used because it provides reusability of code means that write once and use it many times.
It also provides easy modification. Each method has its own name by which it is called.
When the compiler reads the method name, the method is called and performs the specified task.
In this section, we will learn how to call pre-defined, user-defined, static, and abstract methods in Java.
void displayMessage()
{
System.out.println("Non-static method invoked.");
}
Output: