Unsigned Right Shift Operator(>>>): This operator will shift the bits of a number towards
right side by the specified number of positions.
Difference between >> & >>;
When we shift the bits of anumber towards right side by using >> operator, the sign bit of
the input number will be copied as it is into the resultant i.e. positive input will lead to
positive output and negative input will lead to negative output.
When we shift the bits of anumber towards right side by using >>> operator, the sign bit will
be never copied into the resultant. We will always insert a bit Ointo the sign bit of the result.
ie. the result will be always positive, whether the input is positive or negative.
Rule: Bitwise operators can be applied to any combination of numbers without decimal
point(byte, short, int, long, char).
Note: The & | A operators can be applied to any combination of boolean type or any
combination of numbers without decimal point.
7) Conditional Operator: This operator will perform a task based on a condition.
The conditional operator is ?:
Syntax: (condition) ? exp1:exp2
If the condition issatisfied, then it willevaluate the expression(expression1) available after
question mark (?) and if the condition is not satisfied, then it will evaluate the
expression(expression2) available after colon (:). The conditional operator is also called as
ternary operator.
max =(x >y) ?x :y
diff =(x >y)?x-y :y-x
5>6?"hai":"bye"
The conditional operator can be nested any number of times.
2<3? 4>5? "hai": "hello" : "bye"
8) new operator: The new operator is used for creating the
object. Creating an object means
allocating memory for a class in heap memory.
class Student {
Student stu = newStudent(); stu
object
stu is called as the reference Heap
variable.
the reference variable can be any valid It is used to refer or point to an object. The name of
java identifier.