For more understanding on FirstProgram Syntax and Compile time and Runtime Error execute below given test case and see the result comment your result in comment section.
Case 1- Remove '}' at the end of the code then compiler the program, compiler will throw below given compile time error.
Example.java:7: error: reached end of file while parsing
Case 2 - Remove ';' at the end of Sopln statement then compile the program
Case 3 - Remove class name, then compile.
Case 4 - Change S to s in Sopln, then compile
Case 5 - Change args to hari, then compile and execute
Case 6 - Remove String args, then compile and execute
Case 7 - Remove void, then compile
Case 8 - Remove public, then compile
Case 9 - Remove method name, then compile
Case 10 - Remove void, then compile
Case 10 - Remove main method defnition completely, then compile and execute
Case 11 - Remove class definition completely, then compile and execute
Before executing this case remove ".class" from 01Basics folder then try.
Interview Questions on basic Java Programming (Case)
Can we create empty Java file, can we compile and execute it ?
Yes, but after compilation we do not have .class file we can't execute.
In a single Java file how many classes can we define ?
We can define more than one class. The rule is, class names should be different.
In a Java file, how many public classes can we define ?
Only one. We can define one public class and multiple non-public classes.
If we compile multiple classes java file, how many .class file are generated by compiler ?
Compiler generates .class file as many class defined as we have in that java file. Compiler generates .class file separately for every class with class name.
What is user defined method and predefined method ?
Developer written method is called as user defined method or custom method.
Already defined method are called predefined methods.
These mehtod developed by SUN Microsystem developer
What is meant by user defined class and predefined class ?
Developer defined class is called user defined class. Already defined class is called predefined class.