89.2k views
5 votes
Assume the existence of a Window class with a method getClientAreaHeight that returns an integer representing the height of the portion of the window that an application program can use for its display. Assume also, a subclass BorderedWindow with an integer instance variable borderSize, that represents the size of the border around the window.

Required:
Override the getClientAreaHeight in BorderWindowto return the client area height as returned by the superclass minus the border size (taking into account top and bottom borders).

1 Answer

6 votes

Answer:

Following are the code to this question:

public int getClientAreaHeight() //defining a method getClientAreaHeight

{

return super.getClientAreaHeight() - 2 * borderSize;//using the return keyword with the superkey return value

}

Step-by-step explanation:

In the above-given java program code, an integer method "getClientAreaHeight" is defined that returns only the integer value.

Inside the method, the return keyword is used with the super key, which calls the "getClientAreaHeight" method, that subtracts with the 2 times of the "borderSize" variable value.

User Igor Shenderchuk
by
5.1k points