+ 3
In Java can we use import keyword instead of Inheritance for doing the same work?
In java we use extends keyword as Inheritance. But can we use import keyword for the same work? It'll make my program easier.
2 Answers
+ 4
Swarnadeep Ghosh
No bro.
try to understand....
1-->java used package because
they want to access the class file which was kept in other loaction
to acces that file in other location
for eq
D:\folder\packagr\Test.class
E:\folder\package\Test1.class
2-->by default our java program run on a default package...
i.e the only reason implicit compilation can be done by java...
3..
and we know that all. class file of java store in rt.jar
so java already provide the path..
so we just import that. class file from that locations
to our location..
i.e we need import statement..
these work cant be done bu inheritance,untill and unless we dont give the address hardcode
for eq
class A extends java.awt.Frame
{
}
so what we do here we give the whole address here
0
thanks bro