Thread: Inheritance
View Single Post
  #2 (permalink)  
Old 12-07-2007, 08:08 PM
hardwired hardwired is online now
Senior Member
 
Join Date: Jul 2007
Posts: 1,266
hardwired is on a distinguished road
The easiest way to find out is to make up a test app.
Code:
public class MasterTest { public static void main(String[] args) { Master master = new Master(); A a = new A(); // exercise/test your classes... } } class Master { String name; Master(String name) { this.name = name; } public void rideTheHorse() { System.out.println("riding the horse": } // other methods // try methods that return something public String toString() { return name; } } class A extends Master() { // call methods and access fields of superclass }
Can inheritance be private?
Possibly, depends on what you have in mind. We have the private access modifier and the final keyword available. Play with them in your test app.
Reply With Quote