DurgaSoft Java
DurgaSoft Java
> A java source file can contain any number of class & java source file
can be any name.
> A java Source file can contain Atmost one public class. if
the source file have any public class then name should be same
as public class otherwise we will get compile time error saying
case 1: if there is no public class we can give any name to java
source file .
case 2: if there is one class(ex-class B) declared as public
then the name of the public class & name of the java
program (java source file)should be matched otherwise we will get
compile time error saying "class B is public, should be declared
in file named B.java"
case 3:if class B & C are public and the program name is B.java
then also we will get a compile type error saying
"class C is public, should be declared in file named C.java"
> if the class does not contain main method then we will get
runtime excepton saying "NoSuchMethodError:main"
> if we are trying to execute a java class and corresponding
.class file is not available we will get a runtime exception
saying "NoClassDefFoundError:main"
fully qualified statements take less time to compile but short names with
import statement take more time both case have same execution time.
12441559611719