Assume the existence of a Window class with methods getWidth and getHeight, and a subclass TitledWindow, with a constructor accepts a string corresponding to the title of the window.

2
Assume the existence of a Window class  with methods getWidth and getHeight, and a subclass TitledWindow, with a constructor accepts a string corresponding to the title of the window.

LANGUAGE: Java

CHALLENGE:

Assume the existence of a Window class with methods getWidth and getHeight, and a subclass TitledWindow, with a constructor accepts a string corresponding to the title of the window.

Declare a variable , tWindow, of type TitledWindow variable , and initialize it to a TitledWindow object with a title of “My Title”. Print out the width and height of the window (in that order) separated by a space.window (in that order) separated by a space.

SOLUTION:

TiledWindow tWindow = new TiledWindow('My Title");
System.out.println(tWindow.getWidth() + " " +tWindow.getHeight());

2 comments

  • KenM66 says:

    There are misspellings in the above code and an incorrect quotation mark is in the first line. It’s Titled, not Tiled.

    This is the correct code.

    TitledWindow tWindow = new TitledWindow(“My Title”);
    System.out.println(tWindow.getWidth() + ” ” +tWindow.getHeight());

  • j p says:

    It only took this code:

    TitledWindow tWindow=new TitledWindow(“My Title”);
    System.out.println(tWindow.getWidth() + ” ” + tWindow.getHeight());

Add comment