JAVA - "Hello World" with Details - 👑 सार्थक मुंड S3 🤴🏻

JAVA - "Hello World" with Details

JAVA
/* Hello World in JAVA */
public class sarthak
{
   public static void main(String args[])
   {
       System.out.println("Hello World"); // Print the String  
   }

Hello World in JAVA

  • The first line /* Hello World in JAVA */ starting with /* and ending with */ is comment line. This line is optional line, user may write it or may not. This line is used for user documentation. Compiler ignore the comment line.
  • Types :- 
  1. Multi line Comment (/*.......*/)
  2. Single kine Comment (//.........)
  • The keyword public denotes that a method can be called from code in other classes, or that a class may be used by classes outside the class hierarchy. The class hierarchy is related to the name of the directory in which the .java file is located. This is called an access level modifier. Other access level modifiers include the keywords private and protected.  
  • The keyword static in front of a method indicates a static method, which is associated only with the class and not with any specific instance of that class. Only static methods can be invoked without a reference to an object. Static methods cannot access any class members that are not also static. Methods that are not designated static are instance methods and require a specific instance of a class to operate.  
  • The keyword void indicates that the main method does not return any value to the caller.
  • The method name "main" is not a keyword in the Java language. It is simply the name of the method the Java launcher calls to pass control to the program. A Java program may contain multiple classes that have main methods, which means that the VM needs to be explicitly told which class to launch from. 
  • The main method must accept an array of string objects. By convention, it is referenced as args although any other legal identifier name can be used.
  • Printing is part of a Java standard library: The System class defines a public static field called out. The out object is an instance of the PrintStream class and provides many methods for printing data to standard out, including println(String) which also appends a new line to the passed string.  
  • The string "Hello World!" is automatically converted to a String object by the compiler.

Read :-

Java- its Version & Features : Click here
OOP- Object Oriented Programming : Click Here 

Also Read :-

  1. Programs of C

  2. Programs  of C++

  3. Programs of Java

  4. Programs of Python

  5. Codes with HTML, CSS, JS

  6. More Questions & Answers

 



Previous article
Next article

Leave Comments

Post a Comment

Articles Ads

Articles Ads 1

Articles Ads 2

Advertisement Ads