• Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Have any question?

(+91) 98222 16647
info@simplycoding.in
RegisterLogin
Simply Coding
  • Home
  • Courses
  • School
  • Programs
  • Problems
  • Contact Us
  • My account
  • Register

Java Operators

Java Operators

  • Categories Java Operators, Operators, Java
Java Operator

Here we are going to learn above Java Operators. You can watch our video on Java Operators – Click Here

Q. 1 What are operators?
Ans. Operators are special symbols that perform specific operations on Operands
e.g. +, – , <,

Q. 2 What are three classifications of operators?
Ans. Java operators can be classified as unary, binary, or ternary—meaning taking one, two, or three arguments, respectively.

  • Unary: Increment ++, negation –
  • Binary: a + b, num = c
  • Ternary: Conditional Operator ?

Q.3 What is assignment operator?
Ans. Assignment operators is used to assign a value to a variable
Syntax:  < variable > = < expression >
e.g.
double time = 2.10d;
char c = ‘c’;
int counter = 1;
String name = “Nisha”;
boolean rs = true;
counter = 5;       // previous value is overwritten

Q. 4 What are arithmetic operators?
Ans. Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra. There are 8 types of Arithmetic operators

  • Plus (+), Minus (-), Multiply (*), Divide (/)
  • Modulus/ Reminder (%)
  • Increment (++), Decrements (–)

Assuming A is 10 and B is 20

OperatorDescriptionExample
+Addition – Adds values on either side of the operatorA + B will give 30
–Subtraction – Subtracts right hand operand from left hand operandA – B will give -10
*Multiplication – Multiplies values on either side of the operatorA * B = 200
/Division – Divides left hand operand by right hand operandB / A will give 2
%Modulus – Divides left hand operand by right hand operand and returns remainderB % A will give 0
++Increment – Increase the value of operand by 1B++ gives 21
—Decrement – Decrease the value of operand by 1B– gives 19

Q. 5 What are relational operators?
Ans. Relational operators are used to compare two operands. It returns only Boolean value either true or false.
E.g <, >,<=, >=, ==, !=

OperatorDescriptionExample
==Checks if the value of two operands are equal or not, if yes then condition becomes true.(A == B) is not true.
!=Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.(A != B) is true.
>Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.(A > B) is not true.
<Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.(A < B) is true.
>=Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.(A >= B) is not true.
<=Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.(A <= B) is true.

Q.6 What are logical operators?
Ans.
Logical Operators are used to combine one or more relational expressions. It returns true or false value. It operates only on boolean values. E.g a = (b < c) && (d<e)

OperatorDescriptionExample
&&Logical AND operator. If both the operands are non zero then then condition becomes true.(A && B) is false.
||Logical OR Operator. If any of the two operands are non zero then then condition becomes true.(A || B) is true.
!Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.!(A && B) is true.

Q. 7 What is ternary operator in Java?
Ans. Conditional or ternary is the only three argument operator in Java. This operator consists of three operands and is used to evaluate boolean expressions.
Syntax: variable x = (expression) ? value if true : value if false
E.g. b = (a == 1) ? 20: 30;

Q. 8 What is operator precedence?
Ans. The order in which operators are applied is known as precedence. Operators with a higher precedence are applied before operators with a lower precedence.

operator precedence
  • Share:
author avatar
Simply Coding

Previous post

Java Tokens & Data Types
June 16, 2021

Next post

Types of Programming Languages
June 16, 2021

You may also like

Questions on Encapsulation
Questions on Encapsulation
4 July, 2021
Questions on Library classes
Questions on Library classes
4 July, 2021
Questions on String 1
What is Java String?
3 July, 2021

Leave A Reply Cancel reply

You must be logged in to post a comment.

Categories

  • Uncategorized
  • Programs
    • Python
    • Java
  • Problems
    • Python
    • Java
    • Web Development
      • Internet
    • Emerging Technologies
  • Notes
    • General
    • QBasic
    • MS Access
    • Web Development
      • XML
      • HTML
      • JavaScript
      • Internet
    • Database
    • Logo Programming
    • Scratch
    • Emerging Trends
      • Artificial Intelligence
      • Internet of Things
      • Cloud Computing
      • Machine Learning
    • Computer Fundamentals
      • Computer Networks
      • E-Services
      • Computer Hardware
    • Python
    • Java
  • School
    • ICSE
      • Computers Class 9
        • Java Introduction
        • Tokens & Data Types
        • Java Operators
        • Math Library
        • if & switch
        • For & While
        • Nested loops
      • Computer Class 10
        • Sample Papers
        • OOPS concepts
        • Functions in Java
        • Constructors
        • Arrays in Java
        • Strings in Java
    • SSC
      • IT Class 11
        • IT Basics
        • DBMS
        • Web Designing
        • Cyber Laws
      • IT Class 12
        • Web Designing
        • SEO
        • Advanced JavaScript
        • Emerging Tech
        • Server Side Scripting
        • E-Com & E-Gov
      • Computer Science 11
      • Computer Science 12
    • CBSE
      • Computer 9
        • Basics of IT
        • Cyber Safety
        • Scratch
        • Python
      • Computer 10
        • Sample Papers
        • Networking
        • HTML
        • Cyber Ethics
        • Scratch
        • Python
      • Computer Science 11
        • Computer Systems
        • Python 11
          • Python Basics
          • Python Tokens
          • Python Operators
          • Python if-else
          • Python loops
          • Python Strings
          • Python List
          • Python Tuple
          • Python Dictionary
          • Python Modules
        • Data Management
      • Computer Science 12
        • Sample Papers
        • Python 12
          • Python Functions
          • Python File Handling
          • Python Libraries
          • Python Recursion
          • Data Structures
        • Computer Networks
        • Data Management
    • ISC
      • Computer Science 11
        • Introduction to Java
        • Values & Data Types
        • Operators
        • if & switch
        • Iterative Statements
        • Functions
        • Arrays
        • String
        • Data Structures
        • Cyber Ethics
      • Computer Science 12
        • Sample Papers
        • Boolean Algebra
        • OOPS
        • Wrapper Classes
        • Functions
        • Arrays
        • String
Simply Coding Computer Courses for School                Privacy Policy     Terms of Use     Contact Us

© 2021 Simply Coding

Login with your site account

Lost your password?

Not a member yet? Register now

Register a new account

Are you a member? Login now