<< Relentless Reduction Of Complexity | Home | Mark Reinhold: JDK 7 Will Not Ship Until The Java SE 7 JSR Goes Final >>

Wednesday Java Quiz: What Does It Print?

Q: Will the following Java program compile? Run without exceptions? If so, what does it print?

import javax.swing.*;

public class Main {
  public static void main(String[] args) {
    JButton button = new JButton("OK");
    System.out.println(button.isVisible());
  }
}
Tags :


Re: Wednesday Java Quiz: What Does It Print?

This is a great example of a very poorly named method. Maybe the method should be named canBeVisible() or intendsToBeVisible()

Re: Wednesday Java Quiz: What Does It Print?

If I recall correctly, it will print 'true'. The previous commenter is right that the method is somewhat mis-named. It reflects whether the state of the component is set for it to be visible if it is in a top-level container that is visible.

Re: Wednesday Java Quiz: What Does It Print?

it will print true!...

Add a comment Send a TrackBack