0% found this document useful (0 votes)
20 views

Java-class-1-compressed (1)

Java is a high-level, robust, object-oriented programming language developed by Sun Microsystems in 1995, known for its portability and security. It allows for the development of various applications including desktop, web, enterprise, and mobile applications. Key features of Java include simplicity, object-orientation, platform independence, and dynamic capabilities.

Uploaded by

Candy Man
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Java-class-1-compressed (1)

Java is a high-level, robust, object-oriented programming language developed by Sun Microsystems in 1995, known for its portability and security. It allows for the development of various applications including desktop, web, enterprise, and mobile applications. Key features of Java include simplicity, object-orientation, platform independence, and dynamic capabilities.

Uploaded by

Candy Man
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Java

What is Java?
Java is a programming language and a platform. Java is a high level,
robust, object-oriented and secure programming language.

Java was developed by Sun Microsystems (which is now the subsidiary of


Oracle) in the year 1995. James Gosling is known as the father of Java.
Before Java, its name was Oak. Since Oak was already a registered
company, so James Gosling and his team changed the name from Oak to
Java.

Platform: Any hardware or software environment in which a program


runs, is known as a platform. Since Java has a runtime environment (JRE)
and API, it is called a platform.
Java Example

class Simple
{
public static void main(String args[])
{
System.out.println("Hello Java");
}
}
Application

➢Desktop Applications such as acrobat reader, media player,


antivirus, etc.
➢Web Applications such as irctc.co.in.
➢Enterprise Applications such as banking applications.
➢Mobile
➢Embedded System
➢Robotics
➢Games, etc.
Features
The primary objective of Java programming language creation was to
make it portable, simple and secure programming language.

A list of the most important features of the Java language is given


below.

Simple
Object-Oriented
Portable
Platform independent
Secured
Robust
High Performance
Multithreaded
Dynamic
Simple

Java is very easy to learn, and its syntax is simple, clean and easy to
understand. According to Sun Microsystem, Java language is a simple
programming language because:

Java syntax is based on C++ (so easier for programmers to learn it after
C++).

Java has removed many complicated and rarely-used features, for


example, explicit pointers, operator overloading, etc.

There is no need to remove unreferenced objects because there is an


Automatic Garbage Collection in Java.
Object Oriented
Java is an object-oriented programming language. Everything in Java is
an object. Object-oriented means we organize our software as a
combination of different types of objects that incorporate both data
and behavior.

Basic concepts of OOPs are:


Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation
platform independent

Java is platform independent because it is different from other languages like C


, C++
, etc. which are compiled into platform specific machines while Java is a write
once, run anywhere language. A platform is the hardware or software
environment in which a program runs.
There are two types of platforms software-based and hardware-based. Java
provides a software-based platform.
The Java platform differs from most other platforms in the sense that it is a
software-based platform that runs on top of other hardware-based platforms. It
has two components:
Runtime Environment
API(Application Programming Interface)
Java code can be executed on multiple platforms, for example, Windows,
Linux, Sun Solaris, Mac/OS, etc. Java code is compiled by the compiler and
converted into bytecode. This bytecode is a platform-independent code
because it can be run on multiple platforms, i.e., Write Once and Run Anywhere
(WORA).
Secured
Java is best known for its security. With Java, we can develop
virus-free systems. Java is secured because:
➢ No explicit pointer
➢ Bytecode Verifier: It checks the code fragments for illegal
code that can violate access rights to objects.
➢ Java Programs run inside a virtual machine sandbox
Java is portable because it facilitates you to carry the Java bytecode
to any platform. It doesn't require any implementation.

Java is faster than other traditional interpreted programming


languages because Java bytecode is "close" to native code. It is still
a little bit slower than a compiled language (e.g., C++). Java is an
interpreted language that is why it is slower than compiled
languages, e.g., C, C++, etc.

A thread is like a separate program, executing concurrently. We


can write Java programs that deal with many tasks at once by
defining multiple threads. The main advantage of multi-threading
is that it doesn't occupy memory for each thread. It shares a
common memory area. Threads are important for multi-media,
Web applications, etc.
Java is a dynamic language. It supports the dynamic loading of
classes. It means classes are loaded on demand. It also supports
functions from its native languages, i.e., C and C++.

Java supports dynamic compilation and automatic memory


management (garbage collection).
Simple program
class Simple{
public static void main(String args[]){
System.out.println("Hello Java");
}
}

Save the above file as Simple.java.

To compile:
javac Simple.java
To execute:
java Simple
Compilation Flow:
Parameters used in First Java Program
Let's see what is the meaning of class, public, static, void, main, String[],
System.out.println().

class keyword is used to declare a class in Java.

public keyword is an access modifier that represents visibility. It means it is


visible to all.

static is a keyword. If we declare any method as static, it is known as the


static method. The core advantage of the static method is that there is no
need to create an object to invoke the static method. The main() method is
executed by the JVM, so it doesn't require creating an object to invoke the
main() method. So, it saves memory.

void is the return type of the method. It means it doesn't return any value.

main represents the starting point of the program.


String[] args or String args[] is used for command line argument. We
will discuss it in coming section.

System.out.println() is used to print statement. Here, System is a


class, out is an object of the PrintStream class, println() is a method of
the PrintStream class. We will discuss the internal working
of System.out.println() statement in the coming section.

You might also like