Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The questions
- There are
- three
- questions. Answer all
- questions
- .
- 1.
- [10 marks]
- Define a
- Java
- interface
- t
- hat contains
- two
- abstract method
- s matching
- the following requirements:
- a.
- One method is called
- set
- and the other is called
- check
- .
- b.
- Both methods
- take a single
- parameter
- of the same type
- .
- c.
- The
- set
- method has a
- void
- return type and the
- check
- method has a
- boolean
- return type.
- d.
- The
- parameter
- type of
- both methods
- must be
- one of the primitive types:
- double
- ,
- int
- or
- long
- .
- You are free to choose the type.
- Define a
- complete
- concrete class that implements
- your interface
- according to the
- following requirements
- :
- a.
- An instance of the class must store in an instance variable the most recent
- parameter value passed to its
- set
- method.
- b.
- A call to the
- check
- method must return
- true
- if its parameter value is less
- -
- than o
- r equal to the most recent value passed to the
- set
- method
- , and
- false
- othe
- rwise
- .
- c.
- The initial value of the instance variable described above must be set by a
- parameter to the class’s constructor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement