operators

operators

class A{ public static void main(String[]args){ int i=2,k; k=i++ + ++i + +i; System.out.println(k+" "+i); } }

View Answers

March 7, 2012 at 3:27 PM

answer should be i =4 , k = 10

first know the difference between post increment and pre increment. if u dont know,pls refer the google.

Below i mentioned the reason.

it must evaluate right to left.

according to yr code + i == this one wont execute first. because left side variable or value not available. (for ex a+ i or 5+i) so its move next and execute ++i , then it calculate 3 after that i++ should work, that value is also 3. then add the 3+3 +4 = 10.

I hope u understood what i am trying to say. if not plz let me know.









Related Tutorials/Questions & Answers:
Operators
Operators       Operators are symbols that performs some operations on one or more then one operands. Once we declare and initialize variables, we can use operators to perform
Operators
Operators       Operators are symbols that performs some operations on one or more then one operands. Once we declare and initialize variables, we can use operators to perform
Advertisements
ciruit operators.
ciruit operators.  Explain the benefit of short ciruit operators
Java operators
Java operators  What is the difference between the >> and >>> operators
Operators
Operators       Operators are symbols that performs some operations on one or more than one operands. Once we declare and initialize variables, we can use operators to perform
Operators
Operators       Operators are symbols that performs some operations on one or more then one operands. Once we declare and initialize variables, we can use operators to perform
bitwise operators
bitwise operators  Write short note on bitwise operators of Java.   Please visit the following links: http://www.roseindia.net/java/java-tips/data/expressions/slides-bitops.shtml http://www.roseindia.net/java/java
boolean operators in JavaScript
boolean operators in JavaScript  What boolean operators does JavaScript support
logical operators in objective c
logical operators in objective c  logical operators in objective c
operators
operators
operators
SQL OR Operators
SQL OR Operators       The OR operator displays records if any of the conditions is true. 1st Condition 2nd Condition Result false
Unary Operators in java 7
In this section you will learn about the Unary operators. This is one type of operators
Arithmetic Operators in java 7
In this section you will learn about the Arithmetic operators. This is one type of operators
Bitwise Operators in java 7
In this section you will learn about the Bitwise Operators. This is one type of operators
SQL AND Operators
SQL AND Operators       The AND operator displays records if both conditions are true. 1st Condition 2nd Condition Result false
What is the difference between the >> and >>> operators?
What is the difference between the >> and >>> operators?   hi, What is the difference between the >> and >>> operators? Thanks
PHP Operators
Operators in PHP: Every computer language has its own set of operators, most of the operators are same among all languages and  few languages supports some different set of operators. PHP supports mainly three kind of operators
PHP Operators
3.5. PHP Operators Operators are used for performing specific tasks. The operators in PHP are same like other programming languages like Arithmetic operators, Assignment Operators, Comparison Operators, and logical operators. 3.5.1.
difference between == and === operators?
difference between == and === operators?  Is (====) operator available in java or not? difference between
precedence operators c++ example
precedence operators c++ example  What is the precedence of operators in c++ and how does it works?   This might be helpful.. Operator precedence
Java Operators List
Java Operators List  What are the Java operators, please explain and share the Java operator list.   Java Operators List Any Java beginner can easily get confused with the types of Java operators and it can also
Java Operators List
Java Operators List  What are the Java operators, please explain and share the Java operator list.   Java Operators List Any Java beginner can easily get confused with the types of Java operators and it can also
Java Operators List
Java Operators List  What are the Java operators, please explain and share the Java operator list.   Java Operators List Any Java beginner can easily get confused with the types of Java operators and it can also
Java Operators List
Java Operators List  What are the Java operators, please explain and share the Java operator list.   Java Operators List Any Java beginner can easily get confused with the types of Java operators and it can also
Java Operators List
Java Operators List  What are the Java operators, please explain and share the Java operator list.   Java Operators List Any Java beginner can easily get confused with the types of Java operators and it can also
Operators in java 7
This tutorial describes the concept of operators in java 7
Operators and Expressions
Operators and Expressions       Operators: Operators are such symbols that perform some operations on one or more operands. Operators are used to manipulate primitive data
left shift and rigth shift operators
left shift and rigth shift operators   hi some programs for left shift and right shift operators
Operators In Java
Operators In Java In this section we will read about operators in Java. We will illustrate the use of operators in Java using a simple example. Java provides various operators to manipulate the operations in Java. Operators
Arithmetic Operators
Arithmetic Operators Operator is used to perform operation on variable and values. Arithmetic Operators is used to perform arithmetic operations(like... the list of available arithmetic operators : OPERATOR WORK USE
ModuleNotFoundError: No module named 'time-operators'
ModuleNotFoundError: No module named 'time-operators'  Hi, My... named 'time-operators' How to remove the ModuleNotFoundError: No module named 'time-operators' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'simplicial-operators'
ModuleNotFoundError: No module named 'simplicial-operators'  Hi...: No module named 'simplicial-operators' How to remove the ModuleNotFoundError: No module named 'simplicial-operators' error? Thanks   Hi
php Operators
php Operators:       Operators are one of the important feature of every language. In php operators... Error Control Operator Execution Operators Array Operators Type Operators 1
right and left shift operators
right and left shift operators   hi i am jane pls explain the differentiate between right shift and left shift operators   The Left Shift "<<" operator shifts the left operand to the left side
Other Operators in java 7
Other Operators in java 7 In this section you will learn about the Other Operators. This is one type of operators. Conditional Operator (? :): This is also called ternary operator. It contains three operand and two operators
Relational Operators in java 7
Relational Operators in java 7 In this section you will learn about the Equality and Relational operators. This is one type of operators. Equality and Relational Operators : Equality operator checks for equality of operands
AND and OR Operators in MySQL Query
AND and OR Operators in MySQL Query  Hi, How to use the AND and OR Operators in MySQL Query? Thanks   Hi, We have a table with following data: mysql> select * from email
15 Php programs on logical operators
15 Php programs on logical operators  I need 15 example programs for logical operators. Please help me out
bitwise operators accept type char as operands
bitwise operators accept type char as operands   Why bitwise operators accept type char as operands
Assignment Operators in java 7
Assignment Operators in java 7 In this section you will learn about the Assignment Operators. This is one type of operators. Assignment Operators : This operator is used whenever you need to assign some value to your variables. You
The Unary Operators
The Unary Operators in Java   ... operator. In java we have been provided the unary operators so we should know how to make use of those operators.  Unary operators are: ++expr, --expr
ModuleNotFoundError: No module named 'airflow-livy-operators'
ModuleNotFoundError: No module named 'airflow-livy-operators'  Hi...: No module named 'airflow-livy-operators' How to remove the ModuleNotFoundError: No module named 'airflow-livy-operators' error? Thanks   Hi
ModuleNotFoundError: No module named 'airflow-livy-operators'
ModuleNotFoundError: No module named 'airflow-livy-operators'  Hi...: No module named 'airflow-livy-operators' How to remove the ModuleNotFoundError: No module named 'airflow-livy-operators' error? Thanks   Hi
ModuleNotFoundError: No module named 'airflow-livy-operators'
ModuleNotFoundError: No module named 'airflow-livy-operators'  Hi...: No module named 'airflow-livy-operators' How to remove the ModuleNotFoundError: No module named 'airflow-livy-operators' error? Thanks   Hi
ModuleNotFoundError: No module named 'airflow-training-operators'
ModuleNotFoundError: No module named 'airflow-training-operators'  Hi...: No module named 'airflow-training-operators' How to remove the ModuleNotFoundError: No module named 'airflow-training-operators' error? Thanks
Arithmetic Operators
Arithmetic Operators       Arithmetic Operators are used to perform some mathematical... of arithmetic operators are given in a table: Symbol Name
Conditional (Logical) Operators
Conditional (Logical) Operators       Conditional operators return a true or a false value... operators are performed between the two boolean expressions. Symbol Name
Unary Operators
Unary Operators       The unary operators requires only one operand to perform different kind..., or inverting a boolean value. These operators can not be used with final variables

Ads