Java
Java
Dr Resmi K R
James Gosling
○ Earlier name of JAVA is Oak.
○ The “Green” team met at a local coffee shop to come up with another
name...
■Java! (Java is an island in Indonesia where the first coffee was produced
(called Java coffee).
According to Sun, 3 billion devices run java. There are many devices
where Java is currently used. Some of them are as follows:
○ Desktop Applications such as acrobat reader, media player, antivirus etc.
○ Web Applications such as irctc.co.in, javatpoint.com etc.
○ Enterprise Applications such as banking applications.
○ Mobile
○ Embedded System
○ Smart Card
○ Robotics
○ Games etc.
Types of Java Applications
● Java is very easy to learn, and its syntax is simple, clean and easy to
understand.
● Java syntax is based on C++.
● Java has removed many complicated and rarely-used features, for
example, explicit pointers, operator overloading, etc.
Class
● When one object acquires all the properties and behaviors of a parent
object, it is known as inheritance.
● It provides code reusability.
● It is used to achieve runtime polymorphism.
● Inheritance represents the IS-A relationship which is also known as
a parent-child relationship.
Abstraction
Encapsulation
Binding (or wrapping) code and data together into a single unit are
known as encapsulation.
A java class is the example of encapsulation
● Architectural Neutral
● Java is best known for its security. With Java, we can develop virus-
free systems. Java is secured because:
• No explicit pointer
• Java Programs run inside a virtual machine sandbox
Robust
prefix ++expr --expr +expr -expr ~ !
additive +-
Shift shift << >> >>>
Relational comparison < > <= >= instanceof
equality == !=
Bitwise bitwise AND &
bitwise exclusive OR ^
bitwise inclusive OR |
class Simple
{
public static void main(String args[])
{
System.out.println("Hello Java");
}
}
• 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, i
• 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.