Computer Science, asked by guptaakshat571, 9 months ago

Give output of the following Java program:
Int a=5;
a++;
Sopln(a);
a=(a--)-(--a);
Sopln(a);

Answers

Answered by ridhimakh1219
10

Output is a = 6 and a = 2

Explanation:

Java program to evaluate following postfix and prefix expression

a++;

Sopln(a);

a=(a--)-(--a);

Sopln(a);

public class Main

{

public static void main(String[] args) {

        int a=5;  

               a++;    // postfix expression

 System.out.println("a = " +a);

 a=(a--)-(--a);

 System.out.println("a = " +a);

}

}

Output of above program

a = 6

a = 2

Note

int a=5;

Expression a++; evaluates to a = a + 1 = 5 + 1 =6  

Expression a=(a--)-(--a); evaluates to  a = 6 - 4 = 2

Answered by khushidewangan012
3

Explanation:

Program 1

// filename Main.java

class Test {

protected int x, y;

}

class Main {

public static void main(String args[]) {

Test t = new Test();

System.out.println(t.x + " " + t.y);

}

}

Similar questions