Overview of Java Basic Syntax


<aside> <img src="/icons/table_red.svg" alt="/icons/table_red.svg" width="40px" /> Table of Contents

</aside>

<aside> 💡

  1. Basic Terminologies in Java </aside>

<aside> 💡

  1. Syntax: </aside>

Basic Terminologies in Java


Java program is an object-oriented programming language, that means java is the collection of objects, and these objects communicate through method calls to each other to work together. Below is the brief overview on the Classes and Objects , Method , Instance variables , syntax, and semantics of Java.

  1. Class: The class is a blueprint (plan) of the instance of a class (object). It can be defined as a logical template that share common properties and methods.

    1. Example1: Blueprint of the house is class.
    2. Example2: In real world, Alice is an object of the “Human” class.

  2. Object : The object is an instance of a class. It is an entity that has behavior and state.

    1. Example: Dog, Cat, Monkey etc. are the object of “Animal” class.
    2. Behavior: Running on the road.

  3. Method : The behavior of an object is the method.

    1. Example : The fuel indicator indicates the amount of fuel left in the car.

  4. Instance variables : Every object has its own unique set of instance variables. The state of an object is generally created by the values that are assigned to these instance variables.

    1. Sample Hello World Java Program:

      // HelloWord.java file
      
      import java.util.*;
      public class HelloWord {
          public static void main(String[] args)
          {
              System.out.println("Hello World!");
          }
      }
      
    2. Example: Steps to compile and run a java program in a console

      1. Compile

        javac HelloWord.java
        
      2. Run

        java HelloWord
        
    3. Output:

      Hello World!