What is the result?

Given:

3. public class Spock {
4. public static void main(String[] args) {
5. Long tail = 2000L;

6. Long distance = 1999L;
7. Long story = 1000L;
8. if((tail > distance) ^ ((story * 2) == tail))
9. System.out.print(“1”);
10. if((distance + 1 != tail) ^ ((story * 2) == distance))
11. System.out.print(“2”);
12. }
13. }

What is the result?

Given:

3. public class Spock {
4. public static void main(String[] args) {
5. Long tail = 2000L;

6. Long distance = 1999L;
7. Long story = 1000L;
8. if((tail > distance) ^ ((story * 2) == tail))
9. System.out.print(“1”);
10. if((distance + 1 != tail) ^ ((story * 2) == distance))
11. System.out.print(“2”);
12. }
13. }

What is the result?

A.
1

B.
2

C.
12

D.
Compilation fails.

E.
No output is produced.

F.
An exception is thrown at runtime.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Divya

Divya

Ans is ‘E’. No output will be produced in this case.