Name ________________________________________
public class MyPanel extends JPanel implements ActionListener { public void actionPerformed(ActionEvent e) { } }
What is the output from these statements, given the
MyPanel
class as defined above?
Note: Neither JPanel nor its ancestors (superclasses)
implements ActionListener.
JPanel p = new JPanel(); MyPanel myp = new MyPanel(); ActionListener al; al = myp; System.out.println("1. " + (p instanceof JPanel)); System.out.println("2. " + (myp instanceof JPanel)); System.out.println("3. " + (p instanceof MyPanel)); System.out.println("4. " + (p instanceof ActionListener)); System.out.println("5. " + (myp instanceof ActionListener)); System.out.println("6. " + (al instanceof JPanel)); System.out.println("7. " + (al instanceof MyPanel));