Online Examination System for all learner!!! coming soon..

JAVA : Operators

There are four main types of operator.
  • Arithmetic operators
  • The Bitwise operators
  • Relational operators
  • Boolean logical operators

Arithmetic operators:

  • Addition: This operator is used to add the values. It is represented by “+“. For ex: A=a+4.
  • Subtraction:This operator is used to subtract the values. It is represented by “- “.  For example A = a - 4.
  • Multiplication: This operator is used to multiply the values. It is represented by “*“.
    For exampleA=a*4.
  • Division: This operator is used to divide the values. It is represented by “/“. For example: A=a/4.
  • Modulus: This operator is used to find the remainder of the values when divided. It is represented by “%“. For example A = 2 % 4. Where A = 0.
  • Increment: This operator is used to increases its operand by one. It is represented by  “++“. For example a = a++ which is equal to a= a+1.
  • Decrement: This operator is used to decreases its operands by one. It is represented by “—“. For example a = a— which is equal to a= a-1.

Bitwise operators:

  • Unary NOT: This inverts all of the bits of operand contained and it is represented by “~“. For example: ~00101010 = 11010101
  • And: It produces 1 bit if both operands are also 1 and it is represented by “&“. For example:00101010 , &00001111, 000101010.
  • OR: If either of the operand is one it produces 1 and It is represented by “|“. For example:00101010, |00001111, 00101111.
  • XOR: If either of the bit operand is 1, then result is also one otherwise its 0 and it is represented by “^”. For example: 00101010, ^00001111, 00100101.
  • Left shift: It shifts or moves all of the bits in the particular given value to the left side number of times that is been declared and it is represented by ” ≪ ”.
  • Right shift: It shifts or moves all of the bits in the particular given value to the right side number of times that is been declared and it is represented by ” ≫ ”.

Relational operators:

  • Equal to- This relation operator shows that the values are equal to each other and it is represented by “==”.
  • Not equal to- This relation operator shows that the values are not equal to each other and it is represented by “!=”.
  • Greater than- This relation operator shows that one value is greater when compared to other and it is represented by “>”. 
  • Less than-This relation operator shows that one value is less when compared to other and it is represented by “<”.
  • Greater than or equal to- This relation operator shows that one value is greater or equal but not less when compared to other and it is represented by “>=”.
  • Less than or equal to-This relation operator shows that one value is smaller or equal but not greater when compared to other and it is represented by “<=”.

Boolean logical operators:

  • Logical AND- It is represented by “&”.  For example : A & B = If a is false and b is true it results as false, but is both are true it results as true. Similarly when both are false it results as false. 
  • Logical OR- It is signed |. For example: A | B = If a is false and b is true it results as true, but is both are true it results as true. Similarly when both are false it results as false. 
  • Logical XOR- It is shown using “^”. For example: A ^ B = If a is false and b is true it results as true, but is both are true it results as false. Similarly when both are false it results as false. 
  • Logical Unary Not- It is depicted as “!”. For example: ! A = If a is false it results as true, but if a is true it results as false.

Assignment operators:

The assignment is the single equal sign that is represented by “=”.  The general representation
var=expression;
In this the variable, which is represented as var should be compatible with the type of expression.
Int a, b, c;
a = b = c = 100;

The ? Operator
This is used for replacement of if then else statements and it is represented as “?”.
For example:
expression a ? expression b : expression c
This above example states that if the expression a is true then expression b is evaluated otherwise expression c is evaluated.

C Programming Online Test 1

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answ...