+ 1
How will I inherit the methods of a class
suppose I have class x in y package and in y I have another package named z and a class in it as a.. all are public.. if I want to inherit the methods of a in x how can I do that.. my ide is bluej
8 Answers
+ 5
Abhi
fist you have to import the paclagae.
then
you have to set the classpath.
import y.*;
import y.z.*;
class x extends y.z.a
{
}
like this
Note
Multiple inheritance is not allowed in java in case of classes
+ 4
Abhi
extends with package name"." class name
+ 2
Abhi
if you want to run a main class package.
so remember
package is not executable in java.
so if you want to run that class
so you have to do this
java package_name.class file name
at cmd
+ 2
Abhi
yes you can do that
+ 1
i have to inherit multiple classes from that package then
+ 1
here comes a problem. . I want to import classes in one main class and run each class as per user's choice. . so what should I do
+ 1
I got that.. can I move my all classes into packages and later on import them at once
+ 1
then I got my solution