Introduction to Java Programming.

Introduction to Java Programming

Java Programming language is developed by James Gosling at Sun Micro System in the year 1995. It is a simple, portable, architecture-neutral, platform-independent, and object-oriented programming language. 

Why Java is Portable?

Java is known as a Portable language because we can execute the Java code on all major platforms. After compilation, your Java source code gets converted into byte code having a .class extension, and those files can be used on any Java-supported platform without any modification. 

Why Java is called an Architecture-neutral language?

Java is called Architecture neutral because the Java program can run on any processor irrespective of its vendor or architecture. It allows its application to compile on one hardware architecture and to execute on another hardware architecture. 

Why Java is called Platform Independent?

Java is called platform-independent because it can be executed on several platforms and does not depend on any type of platform. It is also known as (WORA) Write Once Run Anywhere. 

Why Java is an Object Oriented Programming language?

Java is an Object Oriented Programming language because without using class concepts we cannot write even a single program in Java. Object-Oriented Programming is faster, and easy to execute, and maintain. It also gives us a clear structure of our program. 

Java can run:

  • In a browser as an Applet. 
  • On the desktop as an Application. 
  • In a server to provide services (database access).
  • Embedded in a device. 
Java Editions:
  • Java Standard Edition (J2SE or JSE): Basic tools and libraries to build applications and applets (Standalone applications).
  • Java Enterprise Edition (J2EE or JEE): Tools and libraries to create servlets, Java server pages, etc (Web application).
  • Java Micro Edition (J2ME or JME): Libraries to create applications to run on hand-held devices such as PDAs and cellular phones (device programs and mobile applications).
The three core packages used in Java Programming are JVM, JRE, and JDK and all three are platform dependent because the configuration of each operating system is different but as we all know that Java is platform-independent. 
  • JDK stands for Java Development Kit and it includes development tools such as the Java compiler, Javadoc, Jar, and debugger. 
  • JRE stands for Java Runtime Environment and it contains the part of Java libraries required to run Java programs and is intended for end users. 
  • JVM stands for Java Virtual Machine. It is an abstract machine that provides a runtime environment in which Java bytecode can be executed. 
Any Java code first compiles into byte code (machine-independent code) then the byte code runs on JVM regardless of the architecture of that machine. 

Java Class File. 
  • A programming language such as C/C++ has 1 step execution. 

C++ compiler

  • Java Programming has two-step execution. 
Java Compiler working

How to write a program in Java?

Any code written in Java is written within a block termed a class. The main method in Java program acts as an entry point signature and all Java programs start their execution from the main method. 

A single Java programming language source file may contain one class or more than one class. If a .java file has more than one class then each class will compile into separate class files. 

Example:


class Student
{
  //block of code
}
class Teacher
{
  //block of code
}
class Hello
{
  public static void main(String[] args)  //main method
  {
    System.out.println("Hello World");
  }
}

After compilation, there will be three class files:- 

  • - Student.class
  • - Teacher.class
  • - Hello.class
The main method has to be declared as public static, takes String[] as an argument, and its return type should be void. 
  • To compile a java code type - javac Filename, java
  • To execute the code type- java Filename
Also read:

⚡ Please share your valuable feedback and suggestion in the comment section below or you can send us an email on our offical email id ✉ algolesson@gmail.com. You can also support our work by buying a cup of coffee ☕ for us.

Similar Posts

No comments:

Post a Comment


CLOSE ADS
CLOSE ADS