Question: java Unless stated otherwise, the retum type of all methods is void, and attributes cannot be accessed outside a class (a) Write Java code for
Unless stated otherwise, the retum type of all methods is void, and attributes cannot be accessed outside a class (a) Write Java code for an interface Trocent that specifies a method briced(). Write Java code for a class Valivin with the following behaviour: It cannot be instantiated directly, but it is a subtype of Trocent. It defines the method briced which simply prints "Waiting". [4 marks) (b) Write Java code for a class Opherol with the following state and behaviour: It cannot be subclassed, but it is a subclass of Valivin . It has an integer class variable called gacity that is initialised to 5 It has an integer instance variable called crimage . It has a no-argument constructor. It refines the method briced inherited from Valivin where the message "Ready" is printed if crimage is divisible by 4, otherwise the parent method briced() is invoked. . It has a toString() method that returns the value of crimage as a String. [8 marks) (c) Determine whether the following statements will compile and run in a client class, clearly explaining your answers. (1) Trocent[] objects = new Valivin[4]; objects[0].briced(); (ii) Trocent t = new Opherol(); (iii) Valivin v = new Trocent(); (iv) Opherol o = new Opherol(); [4 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
