Small code for maths


SUBMITTED BY: itztwpro

DATE: Feb. 24, 2022, 10:16 a.m.

FORMAT: Text only

SIZE: 1.4 kB

HITS: 499

  1. Q-1) What will be the output of the following program?
  2. int i = 4;
  3. int j = 21;
  4. int k = ++i * 7 + 2
  5. System.out.println("k = " + k);
  6. A) K=37
  7. B) Program does not compile
  8. B) K=28
  9. C) k=0
  10. Answer: A) K=37
  11. Q-2) What will be the output of the following program?
  12. int input = 7;
  13. int output = ++input + ++input + ++input;
  14. System.out.println(output);
  15. A) -20
  16. B) 109
  17. B) 27
  18. C) 35
  19. Answer: C) 27
  20. Q-3) What will be the output of the following program?
  21. int i, j, k, l = 0;
  22. k = l++;
  23. j = ++k;
  24. i = j++;
  25. System.out.println(i);
  26. A) 0
  27. B) 1
  28. B) 2
  29. C) 5
  30. Answer: B) 1
  31. Q-4) What will be the output of the following program?
  32. int a = 1;
  33. int b = 2;
  34. int c;
  35. int d;
  36. c = ++b;
  37. d = a++;
  38. c++;
  39. System.out.println("a = " + a);
  40. System.out.print("b = " + b);
  41. System.out.println("c = " + c);
  42. System.out.print("d = " + d);
  43. A) a = 2
  44. b = 3c = 4
  45. d = 1
  46. B) a = 2
  47. b = 3
  48. c = 4
  49. d = 1
  50. C) Program does not compile.
  51. D) a = 1
  52. b = 2
  53. c = 4
  54. d = 2
  55. Answer: A) a = 2
  56. b = 3c = 4
  57. d = 1

comments powered by Disqus