Answer:
<u>Window.java</u>
- public class Window {
- int width;
- int height;
-
- public Window(int width, int height){
- this.width = width;
- this.height = height;
- }
- public int getWidth(){
- return width;
- }
- public int getHeight(){
- return height;
- }
-
- public int getClientAreaHeight(){
- return getHeight();
- }
- }
<u>Main.java</u>
- public class Main {
- public static void main (String [] args) {
- Window win1 = new Window(12, 15);
- System.out.println(win1.getClientAreaHeight());
- }
- }
Explanation:
<u>Window.java</u>
There is a Window class with two int type attributes, width and height (Line 1 - 3).
The constructor of this class will take two inputs, width and height and set these input to its attributes (Line 5 - 8). There are two methods getWidth and getHeight which will return the value of attributes width and height, respectively (Line 10 - 16).
The required new method getClientAreaHeight is defined in line 18 -20. This method will call the getHeight method to return the height value of the window (Line 19).
<u>Main.java</u>
We test the Window class by creating one Window instance and call the getClientAreaHeight method and print the return output (Line 1 -6).
We shall see 15 is printed.
Use a Ghost program follow throught with 2hyttlg5:6\:56
Multiple inheritance causes Diamond problem which happens when:
Class A is parent of class B and C
Now when class D will be inherited from both Class B and C it will have all the members of class A and B which if same will confuse the compiler to import which one?
C++ solves it by using virtual keyword with them and thus telling the compiler which one to inherit.
Java has introduced the interface concept rather then allowing multiple inheritance.
The correct answer would be D
Color's RGB value indicates its red, green, and blue intensity. Each intensity value is on a scale of 0 to 255, or in hexadecimal from 00 to FF.
RGB values are used in HTML, XHTML, CSS, and other web standards. For more, including visual samples and RGB values, see: