• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extends Superclass

 
nani aman
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have 2 classes, both extends JFrame element. i want the Integrity class to be a subclass to Security class so i can call a data member which in integrity class using package but how i can extend in integrity class as its already have extends JFrame?
can it be twice of extends?


public class Security extends JFrame implements ActionListener{
}
public class Integrity extends JFrame implements ActionListener{
}

hopefully somebody help me
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This will do what you want:


Integrity will inherit all public members of Security and also inherit the public members of JFrame that were not overridden by Security.

A child class will inherit members from its parent, its parent's parent, etc., all the way back to java.lang.Object. You have to consider whether each member is public, protected, or default. private members are never inherited.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic