Question

I have created a class called Gui. It needs to extend JFrame and another class called StudentDatabase.

How can I do it ?

Was it helpful?

Solution

You can't extend more than one class in Java.

Instead of using inheritance use composition (extend JFrame and have a member of class StudentDatabase in your class GUI).

Pass invocations of methods in GUI to its member StudentDatabase and voila...

OTHER TIPS

You can't. Java doesn't allow multiple inheritance. In C++ you can do this. In Java you can implement multiple "interfaces", but you'll have to rewrite the implementations of all functions in those interfaces in your class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top