bt0074 unit 3 faqs

Upload: sreilal

Post on 06-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Bt0074 Unit 3 Faqs

    1/1

    Frequently Asked Questions

    1

    Subject Name: OOPS with Java Subject Code: BT0074

    Unit 3: Operators and Control StatementsBalasubramani R

    Assistant ProfessorDept. of IT

    Q1: What are the different kinds of operators in Java?

    A1: Operators play an important role in Java. There are three kinds of operators in Java.

    They are (i) Arithmetic Operators (ii) Comparison / Relational Operators and (iii) Logical

    Operators.

    Q2: What are the various arithmetic operators available in Java?

    A2: Addition (+), Subtraction (-), Multiplication (*), Division (/) and Modulus (%) are the various

    arithmetic operators available in Java.

    Q3: What are the various comparison operators available in Java?

    A3: Equal (==), Not Equal (!=), Less than (), Less than or equal (=) are the various comparison operators available in Java.

    Q4: What are the various logical operators available in Java?

    A4: Short-circuit AND (&&), Short-circuit OR (||), Logical unary NOT (!), Logical AND (&) and

    Logical OR (|) are the various logical operators available in Java.

    Q5: What do you mean by operator precedence? Explain with an example.

    A5: When more than one operator is used in an expression, Java will use operator

    precedence rule to determine the order in which the operators will be evaluated. Forexample, consider the following expression:

    Result = 10+5*8-15/5

    In the above expression, multiplication and division operations have higher priority over

    the addition and subtraction. Hence they are performed first. Now, Result = 10+40-3 =

    47. If you want addition to be performed first, then you should enclose in parenthesis () as

    shown below:

    Result = (10+5)*8-15/5 = 15*8-3 = 117.