Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. The questions
  2. There are
  3. three
  4. questions. Answer all
  5. questions
  6. .
  7. 1.
  8. [10 marks]
  9. Define a
  10. Java
  11. interface
  12. t
  13. hat contains
  14. two
  15. abstract method
  16. s matching
  17. the following requirements:
  18. a.
  19. One method is called
  20. set
  21. and the other is called
  22. check
  23. .
  24. b.
  25. Both methods
  26. take a single
  27. parameter
  28. of the same type
  29. .
  30. c.
  31. The
  32. set
  33. method has a
  34. void
  35. return type and the
  36. check
  37. method has a
  38. boolean
  39. return type.
  40. d.
  41. The
  42. parameter
  43. type of
  44. both methods
  45. must be
  46. one of the primitive types:
  47. double
  48. ,
  49. int
  50. or
  51. long
  52. .
  53. You are free to choose the type.
  54. Define a
  55. complete
  56. concrete class that implements
  57. your interface
  58. according to the
  59. following requirements
  60. :
  61. a.
  62. An instance of the class must store in an instance variable the most recent
  63. parameter value passed to its
  64. set
  65. method.
  66. b.
  67. A call to the
  68. check
  69. method must return
  70. true
  71. if its parameter value is less
  72. -
  73. than o
  74. r equal to the most recent value passed to the
  75. set
  76. method
  77. , and
  78. false
  79. othe
  80. rwise
  81. .
  82. c.
  83. The initial value of the instance variable described above must be set by a
  84. parameter to the class’s constructor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement