227k views
1 vote
Suppose a package pkg1 contains a class named MyClass and another package pkg2 contains a different class named MyClass. What happens when you impot both classes?

User IoctlLR
by
4.9k points

1 Answer

4 votes

Answer:

Following are the solution to this question:

Step-by-step explanation:

In this question, two packages "pkg1 and pkg2" is defined, that hold a class that is "MyClass", in which the class name is the same. If we import the package so, it can't import both classes in the very same file. If we really need to apply to both, then must completely specify one class name, and in the class name is different so, we simply use both classes by creating the instance.

User OrcusZ
by
5.9k points