Program | Java – Object-Oriented Programming

 

Hey all, Welcome to Geeksforjobs

Java – an object oriented language

Was developed by java James gosling. In addition, it was released in the year 1995. It is still the second most commonly used programming language today. It has many advantages such as it is platform-independent, it is secure, dynamic, multithreaded and so on. Its program is converted into machine code one by one.

  • Famous game Minecraft It was also developed by the same programming language.

To run a Java program, you must download:

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

A collection of objects creates Java programs.

Let’s discuss Java programs: object, class, method, and instance variables.

  • thing – An object has behaviors and states. Example: A dog is barking, waving its tail, as well as in states such as breed, color, name. A class example can be any further name.
  • class – It acts as a blueprint. But creates a class object.
  • Ways – We write programs as well as methods inside logics. We can execute all actions inside a method and manipulate it simultaneously. In addition, a class Overloading may be a method or task.
  • instance variables – Each object has a unique set of instance variables. In addition, we can position the object by the values ​​given for the instance variable.

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

  • Note one point if you are writing in 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

Critical part, compilation and execution

Notepad: -Compilation Online Compiler: -Completion
Save this file as Firstprogram.java.
But change your cmd directory to the directory where you saved your program.
Open a command prompt to execute it.
And you compile it first and then execute it.
To comply, write javac FirstProgram.java And press enter, then execute it Java firstprogram.
In conclusion, the output will be Hello world
To execute the program, you must first compile it and then execute it.
In conclusion, the output will be Hello world
Output: - Notepad
Output: – Notepad
Output: -online compiler
Output: -online compiler

Note: – Although online compiler has fewer steps but use notepad because online compiler will not be able to give output properly when you need to do large programs.

The most important point to note:

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

It has huge applications, some of them are:

  • Mobile application
  • Desktop gui application
  • Web based application
  • Scientific application
  • Gaming application
  • Big Data Technologies
  • Cloud-based applications

Uses and Statistics:

  • Over 95% of enterprise desktops run in this language.
  • There are around 9 million Java developers worldwide.

Java is unique because it is dynamic and object oriented, This is why it is used worldwide.


Previous articleIntroduction to VPN (Virtual Private Network)
Next articleA phase of the human reproductive cycle: menstruation

Leave a Comment

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