Javatpoint Logo

can we run or compile a java file without a class name ?

By: patil.*** On: Sat Apr 07 17:39:17 IST 2018     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
Example: filename : sample.java

class {
System.out.println("Hello");
}

if I run => java sample.java
it will compile or not ?
Up0Down
core java  x  328Tags

 
Yes,
you can compile a java file without classname by using javac .java but you can't run a java program without classname.
Image Created0Down

By: [email protected] On: Sun Apr 08 12:57:02 IST 2018 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No