What is the output of following program?
++a or --a is prefix operation, meaning that the value of a will get changed before the evaluation of expression.
lets assume this;
a = 4;
b = a++; // first b will be 4, and after this a will be 5
// now a value is 5
c = ++a; // first a will be 6, then 6 will be assigned to c
- package com.instanceofjava;
- public class A{
- static int a = 1111;
- static
- {
- a = a-- - --a;
- }
- {
- a = a++ + ++a;
- }
- public static void main(String[] args) {
- System.out.println(a);
- }
- }
- 2
No comments:
Post a Comment