Nothing Special   »   [go: up one dir, main page]

Java

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 36

Introduction To Java Programming

Dr Resmi K R

MISSION VISION CORE VALUES


CHRIST is a nurturing ground for an individual’s Excellence and Service Faith in God | Moral Uprightness
holistic development to make effective contribution to Love of Fellow Beings
the society in a dynamic environment Social Responsibility | Pursuit of Excellence
Java History
●Sun Microsystems funded an internal research project “Green” to investigate
a language that is portable.
●The history of Java starts with the Green Team. Java team members (also
known as Green Team), initiated this project to develop a language for digital
devices such as set-top boxes, televisions, etc. However, it was best suited for
internet programming. Later, Java technology was incorporated by Netscape.

James Gosling, Mike Sheridan,


and Patrick Naughton initiated the
Java language project in June 1991.

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

There are mainly 4 types of applications that can be created using


● Standalone Application(J2SE)
 desktop applications or window-based applications.
 traditional software that we need to install on every machine.
 Media player, antivirus etc.
 AWT and Swing are used in java for creating standalone applications.
● Web Application
 An application that runs on the server side and creates dynamic page, is called
web application.
 servlet, jsp, struts, spring, hibernate, jsf etc. technologies are used for creating
web applications in java.
● Enterprise Application(J2EE)
 An application that is distributed in nature, such as banking applications etc. is
called enterprise application.
 In java, EJB is used for creating enterprise applications.
● Mobile Application(J2ME)
 An application that is created for mobile devices. Currently Android and Java
ME are used for creating mobile applications.
1. Simple
2. Object-Oriented
3. Portable
4. Platform independent
5. Secured
6. Robust
7. Architecture neutral
8. Dynamic
9. Interpreted
10. High Performance
11. Multithreaded
12. Distributed
Simple

● 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

● Collection of objects is called class. It is a logical entity.


● A class can also be defined as a blueprint from which you can create
an individual object.
Object
● Any entity that has state and behavior is known as an object.
● An Object can be defined as an instance of a class.
● An object contains an address and takes up some space in memory.
Polymorphism

● If one task is performed in different ways, it is known as


polymorphism. 

In Java, we use method overloading and method overriding to


achieve polymorphism.
Inheritance

● 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

● Hiding internal details and showing functionality is known as


abstraction.
● In Java, we use abstract class and interface to achieve 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

Architecture represents processor


● Platform Independent and portable
Secure

● 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

● The English mining of Robust is strong. Java is robust because:


• It uses strong memory management.
• There is a lack of pointers that avoids security problems.
• Java provides automatic garbage collection which runs on the Java
Virtual Machine to get rid of objects which are not being used by a
Java application anymore.
• There are exception handling and the type checking mechanism in
Java. All these points make Java robust.
Multi-threaded

● 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.
Distributed
Java is distributed because it facilitates users to create distributed
applications in Java. RMI and EJB are used for creating
distributed applications. 
A High Level View Of Translating/Executing Java
Programs
Stage 1: Compilation

Filename.java Java compiler Filename.class


(javac)
Java
Java program bytecode
(generic
binary)
A High Level View Of Translating/Executing Java
Programs (2)
Stage 2: Interpreting and executing the byte code
Machine language
instruction (UNIX)

Filename.class Java interpreter Machine language


(java) instruction (Windows)
Java
bytecode
(generic
binary) Machine language
instruction (Apple)
Tokens
Data types in java
Data Type Default Value Default size

boolean false 1 bit


char '\u0000' 2 byte
byte 0 1 byte
short 0 2 byte
int 0 4 byte
long 0L 8 byte
float 0.0f 4 byte
double 0.0d 8 byte
Operators in Java
● Unary Operator,
● Arithmetic Operator,
● Shift Operator,
● Relational Operator,
● Bitwise Operator,
● Logical Operator,
● Ternary Operator and
● Assignment Operator
Operator Type Category Precedence

Unary postfix expr++ expr--

prefix ++expr --expr +expr -expr ~ !

Arithmetic multiplicative */%

additive +-
Shift shift << >> >>>
Relational comparison < > <= >= instanceof

equality == !=
Bitwise bitwise AND &

bitwise exclusive OR ^

bitwise inclusive OR |

Logical logical AND &&


logical OR ||
Ternary ternary ?:
Assignment assignment = += -= *= /= %= &= ^= |= <<=
>>= >>>=
Simple.java

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.

You might also like