Computer Applications
Give the output of the following method:
public static void main (String [] args){
int a = 5;
a++;
System.out.println(a);
a -= (a--) - (--a);
System.out.println(a);}
Java
Java Operators
ICSE 2014
110 Likes
Answer
6
4
Working
- a++ increments value of a by 1 so a becomes 6.
- a -= (a--) - (--a)
⇒ a = a - ((a--) - (--a))
⇒ a = 6 - (6 - 4)
⇒ a = 6 - 2
⇒ a = 4
Answered By
57 Likes
Related Questions
A store has purchased some cola cans of various brands. It purchased 50 cans @ ₹15 per can, 30 cans @ ₹20 per can and 40 cans @ ₹21 per can. Write a Java program to compute how much amount did the store pay.
if (a>b&&b>c) then largest number is:
- b
- c
- a
- wrong expression
Write a Java program to obtain principal amount, rate of interest and time from user and compute simple interest.