Advanced Java Output-Based Questions
1. Convert the following mathematical expression to Java code and evaluate: 3a² + 2b -
√8 ab
2. What is the output of the following code?
int x = 5;
int y = ++x * 2 + x--;
[Link](y);
3. Predict the output:
double a = 9.0 / 2;
int b = (int)(a + 0.5);
[Link](b);
4. Evaluate the Java expression: int x = 10; x += x++ + ++x; What is the value of x?
−b ± √ b 2−4 ac
5. Convert 2³ + in Java using Math functions.
2a
6. What will be the output?
int x = 3, y = 4;
x *= y + 2;
[Link](x);
7. Convert: (a² + b² - 2ab) / 2 to Java.
8. What is the result of:
double x = [Link](2, 3) + [Link](4.2) - [Link](3.9);
[Link](x);
9. Output of:
int a = 5;
a = a++ + ++a;
[Link](a);
10. Convert and evaluate: |a - b| + [Link](a² + b²), where a = 6, b = 8.
11. Output?
double result = (int)3.6 + (int)4.5 + 1.2;
[Link](result);
12. What is printed?
int x = 4, y = 2;
int z = x++ * --y + x;
[Link](z);
13. Predict:
double x = [Link](25) + [Link](3, 2);
[Link]((int)x);
14. Convert to Java and compute: 2ab + b², for a = 3, b = 4.
15. Output?
int x = 5;
x = ++x + x++ + --x;
[Link](x);
16. Convert and solve: a³ + b² + c, where a = 2, b = 4, c = 6.
17. What does this print?
double a = 5.5;
int b = (int)a + 10;
[Link](b);
18. Evaluate: [Link](-10) + [Link](2, 4) / [Link](16)
19. Result?
int x = 7, y = 2;
[Link](x / y * y + x % y);
20. Solve: Convert (a + b)² and evaluate for a = 3, b = 2.
21. What is printed?
float x = 6.7f;
int y = (int)x;
[Link](y);
22. Convert to Java: (ab + bc + ca)/3 for a=2, b=4, c=6.
23. Output?
int x = 2, y = 3;
[Link](++x * y-- + --y);
24. Result?
double d = 8.0/3;
[Link]((int)d * 3);
25. Convert and evaluate: [Link](a² + b² + c²), where a=1, b=2, c=3.
26. What will this code print?
int a = 10;
a += a++ + ++a;
[Link](a);
27. Evaluate:
double x = [Link](2.6f) + [Link](1.1);
[Link](x);
28. Convert: (a + b) * (a - b), a = 7, b = 4.
29. Output?
int x = 10, y = 5;
int z = x++ - --y + ++x;
[Link](z);
30. What is printed?
double x = 3.14159;
int y = (int)x;
[Link](y);
31. Convert and solve: (a² - b²)/(a + b), a = 9, b = 4.
32. Predict:
double d = [Link](2, 3) + [Link](36);
[Link](d);
33. Output of:
int x = 5;
int y = ++x + x++ + --x;
[Link](y);
34. Convert and solve: |a + b - c| + [Link]² for a=3, b=4, c=2.
35. What is printed?
int a = 4;
a = a++ + ++a - --a;
[Link](a);
36. Evaluate:
double x = (int)(5.6 + 3.1) * 2;
[Link](x);
37. [Link]( 0 != 0) ;
Determine the type of Output .
38. Output?
int a = 2, b = 5;
[Link](++b - a++ + --a);
39. Evaluate:
double d = [Link](7.9) + [Link](0.1);
[Link](d);
40. Arrange the Operators in Descending order .
float
char
byte
short
int
41. Output of:
int x = 3, y = 6;
[Link](y / x + y % x);
42. Evaluate:
float f = 7.6f;
int i = (int)f % 3;
[Link](i);
43. int num = "100";
Determine the type of error
44. int a = 10, b = 20;
int max = (a > b) ? a : b;
[Link]("Minimum is: " + max);
45. int a = 5;
double b = 6.2;
float c = 4.5f;
varesult = a + b * c;
46. Output?
int a = 3, b = 2;
[Link]((a + b++) * --a);
47. Convert: [Link](a² + b² - 2ab), a = 6, b = 4.
48. Result?
double d = 10.0 / 4 + 3 * 2;
[Link](d);
49. double radius = 5;
double area = 2 * 3.14 * radius;
[Link]("Area = " + area);
Determine the type of error in the code .
50. What will this print?
int x = 8;
x = x++ - --x + ++x;
[Link](x);