Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. CSE 234, LAB FINAL
  2. MARKS: 100, TIME: 30 MIN
  3. [*Create a folder named after your registration number on the desktop and keep all answer files in there*]
  4. [*All class, method and variable names that are provided should be kept same(case sensitive) as it is.*]
  5. Q1. Write a java class using the following information: 20
  6. public class S {
  7. public static void changeMainThread(int sec, int priority) {
  8. . . .
  9. . . .
  10. }
  11. public static void main (String args[]) {
  12. S.changeMainThread(3, 9);
  13. }
  14. }
  15. OUTPUT:
  16. Current Thread: Thread[main,5,main]
  17. Current Thread: Thread[ExamThread,9,main]
  18. Threading is trying sleeping for 3s...
  19. Sleeping complete!
  20. Q2. Write two java class file using the following information: 35
  21. public abstract class A {
  22. private int ai;
  23. ...
  24. ...
  25. public int am1() { return ai; }
  26. public abstract void am2(String s); // Prints reversed string.
  27. }
  28. public class B extends A {
  29. private int bi;
  30. ...
  31. ...
  32. public void bm() {
  33. System.out.println("ai : " + am1() + "\nbi : " + bi);
  34. }
  35. ...
  36. ...
  37. public static void main(String args[]) {
  38. B b = new B(10,20);
  39. b.bm();
  40. A a = b;
  41. a.am2("APPLE");
  42. }
  43. }
  44. OUTPUT:
  45. ai : 10
  46. bi : 20
  47. ELPPA
  48. Q3. Write two java class file using the following information: 25
  49. interface I {
  50. int fi = 5;
  51. void im(int n);// prints factorial of n
  52. }
  53. public class C extends B implements I {
  54. ...
  55. ...
  56. ...
  57. public static void main(String args[]) {
  58. C c = new C(40,25);
  59. c.bm();
  60. c.am2("Factorial");
  61. c.im(c.fi);
  62. S.changeMainThread(2,8);
  63. }
  64. }
  65. OUTPUT:
  66. ai : 40
  67. bi : 25
  68. lairotcaF
  69. 120
  70. Current Thread: Thread[main,5,main]
  71. Current Thread: Thread[ExamThread,9,main]
  72. Threading is trying sleeping for 3s...
  73. Sleeping complete!
  74. Q4. Create packages with the class files from Q1-3 accordingly so that all previous codes works as it should be.
  75. Package folders should be directly under the Registration number directory. Packages: 20
  76. Package Name Class
  77. p1 S
  78. p2 A
  79. B
  80. p3 I
  81. C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement