1. Introduction to Java – Difficulty Level : Easy

1. Introduction to Java

Java Programming Language :

understand java before Introduction to Java: Java is among the most extensively employed programming languages.

  • Java has been among the most used programming languages for a long time.
  • Java is Object Oriented. However, it cannot be thought of as pure object-oriented since it allows support for simple data formats (like int or char)
  • The Java code is first converted into bytes (machine-independent code). The byte code then runs on the the Java Virtual Machine (JVM) regardless of the architecture used.
  • Java syntax is identical to C/C++ syntax. But Java does not provide low-level programming functionalities like pointers. Furthermore, Java codes are always written as objects and classes.
  • Java is utilized in a variety of applications such as Mobile Applications (Android is Java-based) Desktop applications, web applications enterprise applications, client-server apps and more.
  • If you compare it to C++, Java code is generally more stable since Java doesn’t allow for numerous things that can cause inefficient or bad programming when used improperly. For instance, non-primitives refer to references only in Java. Therefore, we can’t transfer large objects (like we do with C++) to functions. We always pass references using Java. Another example, because there are no pointers in Java, the possibility of bad access to memory is impossible.
  • When compared to Python, Java kind of is a cross in between C++ and Python. The programs written in Java generally are faster than Python programs, but more slowly as C++. As with C++, Java performs static type checking, however, Python does not.


Simple Hello World Program :

// A Java program to print “Hello World”
public class TQ{
public static void main(String args[])
{
System.out.println(“Hello World”);
}
}

Output:

Hello World
Also Read : How to Introduce Yourself to the Students – Magic Lesson 2022

Introduction to Java

JAVA has been created by James Gosling at Sun Microsystems Inc in 1995 which was later purchased in the year 1995 by Oracle Corporation. It is a basic programming language. Java helps in writing, compiling and debugging programming simple. It allows you to write reusable software and modular programming.

Java is an object-oriented programming language that is based on classes. language that is made to have as minimal dependences on implementation as it is feasible. It is a general purpose programming language designed specifically for programmers that can write once and run everywhere that has been compiled. Java code is compatible with any platform that supports Java. Java applications are written in byte code that runs in all Java Virtual Machine. Java’s syntax Java can be compared to that of c as well as c++.

The history :

Java’s history is very fascinating. It’s a programming language developed in the year 1991. James Gosling, Mike Sheridan, and Patrick Naughton, a team comprised of Sun engineers referred to as the Green team, initiated Java as a Java language in the year 1991. Sun Microsystems released its first version of the Java language in 1996, dubbed Java 1.0. It offers no-cost run-times on the most popular platforms. Java1.0 compiler was modified using Java by Arthur Van Hoff to strictly conform to the specifications of Java. After the release of Java 2, new versions included multiple configurations for different kinds of platforms.

The year 1997 was the time that Sun Microsystems approached the ISO standards body, and then established Java however, it later pulled out of the process. At one point, Sun made most of its Java applications available for free despite their status as proprietary software. Sun earned revenue from Java by selling licences for products that were specialized, like for instance the Java Enterprise System.

On the 13th of November in 2006, Sun made available a significant portion of the Java virtual machine to be open-source, free software. On May 8 7, 2007, Sun concluded the process by making its Java Virtual Machine’s core code accessible under the terms of open-source distribution.

The principles that led to the creation of Java were easy, reliable and secure, as well as high performance multi-threaded, portable and interpreted, dynamic etc. In 1995, Java was created through James Gosling who is regarded as the founder of Java. Presently, Java is used in mobile devices, internet-based programming games, e-commerce and more.

Java programming language known as JAVA. Why?

Following the name OAK The team decided to come up with the company a brand new name and the words suggested included Silk Jolt, Silk revolutionary, DNA dynamic and so on. The names were all easy to pronounce and enjoyable say, however they all wanted to convey the fundamentals of technology. According to James Gosling, Java was most sought-after name alongside Silk , and because Java was a distinct name, the majority of people preferred it.

Java is the title given to the island located in Indonesia which is where the first coffee(named Java coffee) was made. This name was selected from James Gosling while having coffee near his office. It is important to note that Java is only a name, and it is not an acronym.

Java Terminology

Before beginning to learn Java it is essential to be aware of these commonly used phrases of Java.

1. Java Virtual Machine(JVM) : It is often referred to as JVM. There are three stages of execution of an application. They are writing, compiling and then run the program.

  • Writing programs is performed by a Java programmer just like me and you.
  • The compilation process is performed through JAVAC, the JAVAC compiler, which is a principal Java compiler that is part of the Java development kit (JDK). It uses Java’s Java program as an input and outputs bytecode.
  • In the running in the Running phase that a software program runs the JVM runs the code that was generated from the compiler.

Then, we realized that the primary function of the Java Virtual Machine is to run the bytecode generated from the computer. Each operating System has a distinct JVM, but the output that they generate following the execution of bytecode is the same for every operating system. This is the reason Java is referred to as an independent language that is platform-independent.

2. Bytecode is used in the development process: As we have discussed in the previous article, the Javac compiler in JDK compiles Java source code into bytecode , so that it can be run by JVM. It is saved as a .class file by the compiler. To examine the bytecode an disassembler such as Javap can be used.

3. Java Development Kit(JDK) The reason we have used JDK to describe the concept of bytecode and JVM. The name implies, it’s an entire Java development kit which includes everything from compilers, Java Runtime Environment (JRE) Java debuggers, Java documentation. In order for the program to run in Java, we have first install JDK on our PC for us to build and run the Java program.

4. Java Runtime Environment (JRE): JDK includes JRE. JRE installation on our PCs lets Java programs run, but we can’t build it. JRE comes with browser, JVM, applet supports and plug-ins. To run the Java program the computer requires JRE.

5. Garbage Collector: In Java the programmers cannot delete objects. To erase or recover that memory JVM includes a program known as Garbage Collector. Garbage Collectors are able to recollect objects that aren’t associated with. Thus, Java helps make the life of a programmer simple through the management of memory. However, they must be aware of their code regardless of whether they’re using the same objects in use for a lengthy period. Garbage is unable to retrieve the memory of objects that are referenced.

6. ClassPath: This is the path to the file where Java runtime as well as the Java compiler are looking to find .class documents to open. As a default feature, JDK provides many libraries. If you wish to add additional libraries, they must be included in the classpath.

Primary/Main Features of Java

1. Platform independent: Compiler converts source code into bytecode , and the JVM executes the bytecode produced from the compiler. The bytecode runs on any platform whether it’s Windows, Linux, or macOS so that if we build an application on Windows and then execute it using Linux and reverse. Each operating system runs an individual JVM however the output generated by the operating systems is the same following the execution of bytecode. That’s why we call Java a language that is platform independent.

2. Object-Oriented programming language: organizing the program according to the concept of objects as collections is an aspect of object-oriented programming. Each of that represents an individual instance within the class.

The four fundamental ideas of Object-Oriented programming:

  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism

3. Simple: Java is among the most basic languages because it does not include complex functions like pointers, operators overloading and multiple inheritances and explicit memory allocation.

4. Robust: Java language is robust, which is a sign of reliability. It was designed in a manner that it devotes a great deal of effort into identifying the errors as soon as it is possible. That is the reason Java compilers are capable of detecting errors that aren’t easy to spot by a different programming language. The most important features of java that makes it more robust include garbage collection, Exception Handling as well as memory allocation.

5. Secure: Java do not have pointers, which means we can’t access out-of-bound arrays i.e it displays an ArrayIndexOutOfBound Error when we attempt to access it. This is why security vulnerabilities, such as buffer overflow or stack corruption cannot be exploited in Java. Java programs also run in a context that is independent from that of the os(operating software) environment. This makes Java applications more safe .

6. Distributed: We can develop distributed applications with the Java programming language. Remote Method Invocation, Enterprise Java Beans can be utilized to create distributed applications using Java. Java applications are easily distributed across multiple systems that are linked to one another via Internet connectivity.

7. Multithreading: Java supports multithreading. It is an Java feature that permits concurrent processing of several elements of a program, allowing for the maximum use of CPU.

8. Portable: As we are aware, java code that is written on one machine is able to be run on a different machine. Java’s feature that is platform-independent which allows for bytecodes that are platform-independent can be transferred to any platform to run allows Java to be portable.

9. The High-Performance: Java technology is structured in a way so that it minimizes overhead at the runtime. In addition, at certain times, Java uses Just In Time (JIT) compiler , where the compiler compiles the code on-demand fundamentals, and only compiles the methods that allow applications run faster.

10. Flexible and dynamic: Java being completely object-oriented allows us to add classes, new methods , existing classes and even develop new classes using sub-classes. Java also supports functions written in different languages, such as C, C++ that are known as native methods.

11. Sandbox Execution: Java applications run in a separate area that lets users run their programs without impacting the system in the background with the aid of a bytecode verification. Bytecode verification also offers additional security because its function is to verify the code for any infringement of access.

12. Write Once Run Anywhere: As discussed above java application generates a ‘.class’ file which corresponds to our applications(program) but contains code in binary format. It offers an architecture-neutral experience since bytecode isn’t dependent on the architecture of any machine. This is the main reason why Java is employed in the thriving IT sector across the globe.

13. The power of compilation and interpretation: Most languages are usually designed for a specific purpose, whether they are compiling or are an interpretable languages. However, Java integrates the two to create a huge potential in the sense that Java compiler compiles source code to bytecode . JVM runs this bytecode as executable code that is dependent on the OS of the machine.

Example

// Importing classes from packages
import java.io.*;

// Main class
public class TQ{

// Main driver method
public static void main(String[] args)
{
// Print statement
System.out.println(“Welcome to Techyquote”);
}

}

Output:

Welcome to Techyquote

Explanation:

1. Comments: Comments are utilized to explain code. They can be used in the same method when using Java and C as well as C++. Compilers do not consider comments and don’t execute comments. Comments can be on one line or more lines.

Single Line Comments:
Syntax: // Single line comment

Multi-line comments:
Syntax:/* Multi line comments*/

2. import java.io.*: The * indicates that that all the classes of the io package are able to be importable. Java Io package offers the streaming streams for inputs and outgoings that are suitable for writing and reading data into files, or to other input or output sources.

3. Class: The class contains the information and techniques to be employed within the program. Methods determine the behavior that the classes perform. The class TQ has one method The main method in JAVA.

4. static main (): static keyword indicates that this method can be used without having to create the class.

5. void: The keywords in void tell us that this method won’t provide any results. The primary () method is the main entry point for our application.

6. System.in: It is the input stream standard that reads characters directly from keyboards or any other input device.

7. System.out: It is the output stream that is standard which is used to display the output of a program in an output device such as the computer’s display.

8. println(): println() in Java can also be employed to display text on consoles. It prints the text onto the console, and the cursor shifts to the beginning on the following line in the console. The next printing occurs at the beginning of on the following line.

9. String []args: The String argument will be the argument that is passed by the primary function that comprises a string array that has the name array args. It is possible to choose a names, but this name is widely used by developers.

All Java-related information is presented in Class as an object that includes the main function.

Recent Articles

WPC2026 Live Dashboard: Login Register and Troubleshooting Guide

WPC2026 Live Dashboard WPC2026 Live Dashboard: You've probably come across the Wpc2026 live login on the...

How to Create a WPC2023 Account? – Guide to Register & Login for WPC2023 Live

How to Create a WPC2023 Account? Guide to Register & Login for WPC2023 Live Create a WPC2023 Account : Sports...

How to Add Bluetooth to Any PC (Easy Guide 2022)

How to Add Bluetooth to Any PC Add Bluetooth to Any PC: Modern electronic...

Sw418 Login Sabong Online Register Complete Guide 2022-23

Sw418 Login to Sabong Online Registration: Sw418 Login: Visitors to Sw418's official website will...

WPC2023 live: A Complete Guide on Register & Login for WPC2023 Live

WPC2023 Live: WPC2023 is a worldwide event that will be held at various locations around the world.

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox