Hi,
I have to two
java programs in the same directory.
say JavaFile1.java and
JavaFile2.java
And in JavaFile1.java,
has two classes A and B
Now in JavaFile2.java ,
has two class definitions for A1 and B1
but unfortunately in this JavaFile2.java,instead of creating object for A1 ,i have created object for A as follows. Actually there should be statement
A1 ob=new A1();
but i have created it like this
A ob=new A();
Now , my doubt is when i run the second program i.e., JavaFile2.java,
Even though there is no class named A inside this, the compiler is not pointing out.
It's simply creating an object of class and is invoking its A's no-arg constructor into JavaFile2.java
NOTE::No import statements used
Can anyone let me know the reason.
Thanks.