Connect with us

Application of Java

Java – An Object-Oriented Programming

Published

on

Java was developed by James Gosling. Besides, it releases in the year 1995. Even today it is the second most used programming language. It has many advantages like it is platform-independent, it is secure, Dynamic, multithreaded, and so on. Its program is converted one – by- one in machine code.

  • The famous game Minecraft was also developed by this very same programming language.

To run the Java program, you have to download these: 

  • Linux or Windows operating system
  • Java JDK 12(or any available version will do)
  • Microsoft Notepad

Collection of objects makes a Java program.

Let us discuss the Java Program: Object, Class, Method, and Instance variables.

  • Object – An object has behaviours and states. Example: A dog has the behaviour of barking, wagging their tail, as well as states like breed, colour, name. A class instance can be another name forth.
  • Class – It acts as a blueprint. But class creates objects.
  • Methods – We write programs as well as logics inside methods. We can manipulate as well as we can execute all the actions inside a method. Besides, a class can be overloading method or function.
  • Instance variables – Every object have a unique set of instance variables. Moreover, we can create the object’s state by the values assigned to the instance variables.

Let’s see a simple program, write the below code in notepad

  • Note a point if you are writing in a notepad, you do not need to write public in the first statement.
Notepad Online compiler
class FirstProgram

   /* This is a simple program to print any statement.
    * We are printing hello in this program.
    */
   public static void main(String []args)
      System.out.println(“Hello World”); // prints Hello World
   
public class FirstProgram

   /* This is a simple program to print any statement.
    * We are printing hello in this program.
    */
   public static void main(String []args)
      System.out.println(“Hello World”); // prints Hello World
   
Program:-Notepad
Program:-Notepad
Program:-Online Compiler
Program:-Online Compiler

   

The important part, compilation and execution

Notepad:-Compilation Online Compiler:-Compilation
Save this file as Firstprogram.java.
But change your cmd directory to the directory where you’ve saved your program.
To execute this open the command prompt.
And you’ve to compile it first and then execute it.
To complies, write javac FirstProgram.java and press enter, then execute it with java FirstProgram.
In conclusion, the output will be Hello World.
To execute the program, you’ve to compile it first and then execute it.
In conclusion, the output will be Hello World.
Output:- Notepad
Output:- Notepad
Output:-Online Compiler
Output:-Online Compiler

Note:- Though online compiler has fewer steps but use the notepad instead because when you need to do large programs online compiler will not able to give the output properly.

Most important points to note:

  • The first letter of the class name is always in upper case.
  • Methods should start with lower case.
  • Always remember the class name and file name should be same. Moreover, it is case-sensitive.

It has vast application, some of them are:

  • Mobile Applications
  • Desktop GUI Applications
  • Web-based Applications
  • Scientific Applications
  • Gaming Applications
  • Big Data technologies
  • Cloud-based Applications

Uses and Statistics:

  • More than 95% of Enterprise Desktops run in this language.
  • There are almost 9 Million Java Developers worldwide.

Java is unique as it is dynamic and Object Oriented, this is why it is used worldwide.

The post Java – An Object-Oriented Programming appeared first on GeeksGod.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Newsletter

Trending

Copyright © 2019 - 2020