java ppt
TRANSCRIPT
J AVAA Brief Introduction…
Submitted by-Dilip Kumar Jangir
Branch-Information TechnologyRoll No.-12EARIT019
What is Java?
Java is a general purpose, high-level programming language developed by Sun Microsystems.
A small team of engineers, known as the Green Team, initiated the language in 1991.
Java was originally called OAK, and was designed for handheld devices and set-top boxes.
Today, Java is a commonly used foundation for developing and delivering content on the Web.
Characteristics of Java
Java is- Simple. Object-oriented. Distributed. Interpreted. Robust. Secure. Architecture-neutral. Portable. Multithreaded. Dynamic.
Java Virtual Machine(JVM)
Java is both compiled and interpreted. Source code is compiled into Java bytecode. Which is then interpreted by the Java Virtual Machine (JVM). Therefore bytecode is machine code for the JVM.
Java bytecode can run on any JVM, on any platform including mobile phones and other hand-held devices.
Networking and distribution are core features. Makes Java very good for building networked applications, server side
components, etc. In other languages these are additional APIs.
Features of JVM
The Garbage Collector Runs in the background and cleans up memory while application is running. Java manages memory for you, the developer has no control over the
allocation of memory (unlike in C/C++). This is much simpler and more robust (no chance of memory leaks or
corruption). The Just In Time compiler (JIT)
Also known as “Hot Spot”. Continually optimises running code to improve performance. Can approach the speed of C++ even though its interpreted.
(Cont.)Features of JVM
Security Java offers very fine control over what an application is allowed to do. E.g. Read/write files, open sockets to remote machines, discover information
about the users environment, etc. Used in Java Applets to create a “sandbox”. Stops a rogue applet attacking your
machine. Makes Java very safe, an important feature in distributed systems.
Class Loading Loading of bytecode into the virtual machine for execution. Code can be read from a local disk, over a network, or the Internet. Allows downloading of applications and applets on the fly.
Versions of Java
JDK Alpha and Beta(1995) JDK 1.0(January 23,1996) JDK 1.1(February 19,1997) J2SE 1.2(December 8,1998) J2SE 1.3(May 8,2000) J2SE 1.4(February 6,2002) J2SE 5.0(September 30,2004) J2SE 6.0(December 11,2006) J2SE 7.0(July 28,2011) J2SE 8.0(March 18,2014) J2SE 9.0 & 10.0 are scheduled to release in 2016 & 2018
respectively.
Data TypesIn Java, there are two categories of data types-1. Primitive Data Types 2. Non-Primitive Data Types
Data Type Default Type Default Sizeboolean False 1 bitchar ‘\u0000’ 2 bytebyte 0 1 byteshort 0 2 byteint 0 4 bytelong 0L 8 bytefloat 0.0f 4 bytedouble 0.0d 8 byte
Naming ConventionsJava Naming Convention is a rule to follow as you decide what to name
your identifiers such as class, package, variable, constant, method, etc.
Name Conventions
Class Name Should start with uppercase letter and be a noun e.g. String, Colour, Button, Thread, etc.
Interface Name Should start with uppercase letter and be an adjective e.g. Runnable, ActionListener, etc.
Method Name Should start with lowercase letter and be a verb e.g. actionPerformed(), main), println(), etc.
Variable Name Should start with lowercase letter e.g. forstName, orderNumber, etc.
Package Name Should be in lowercase letter e.g. java, lang, sql,util, etc.
Constant Name Should be in uppercase letter e.g. RED, YELLOW, MAX_PRIORITY, etc.
Java OOP’s Concept
Object Oriented Programming is a paradigm that provides many concepts such as inheritance, data binding, polymorphism etc.
Java concepts- Object Class Inheritance Polymorphism Abstraction Encapsulation
Object
An entity that has state and behavior is known as an object e.g. chair, bike, marker, pen, table, car etc.
An object has three characteristics: State- represents data(value) of an object. Behaviour- represents the behaviour (functionality) of an
object such as deposit, withdraw, etc. Identity- Object identity is typically implemented via a unique
ID. The value of the ID is not visible to the external user but, it is used internally by the JVM to identify each object uniquely.
Object is an instance of a class.
Class
A class is a group of objects that has common properties. It is a template or blueprint from which objects are created.
A class in java can contain- Data member Method Constructor Block Class and interface
By default, all data members and methods are private in Java.
Example of Classclass Student{
int age;String name;void printData(){
System.out.println(“Name:”+name+”\nAge:”+age);
}public static void main(String args[]){
Student st=new Student();st.name=“John”;st.age=22;st.printData();
}}
Inheritance
Inheritance in java is a mechanism in which one object acquires all the properties and behaviors of parent object.
The idea behind inheritance in java is that you can create new classes that are built upon existing classes.
Inheritance represents the IS-A relationship, also known as parent-child relationship.
It provides the mechanism of usability of code. The extends keyword is used to derive a new class from
existing class.
Types of Inheritance
Single Multilevel Hierarchical
Java does not support Multiple Inheritance because it creates the ambiguity in the program.
Polymorphism
Polymorphism in java is a concept by which we can perform a single action by different ways. Polymorphism is derived from 2 greek words: poly and morphs.
The word "poly" means many and "morphs" means forms. So polymorphism means many forms.
There are two types of polymorphism in java: Compiletime Polymorphism Runtime Polymorphism
We can perform polymorphism in java by method overloading and method overriding.
Method Overloading
If a class have multiple methods by same name but different parameters, it is known as Method Overloading.
Method overloading increases the readability of the program.
There are two ways to overload the method in java: By changing number of arguments. By changing the data types.
Method Overriding
If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in java.
Usages- Method overriding is used to provide specific
implementation of a method that is already provided by its super class.
Method overriding is used for runtime polymorphism Rules-
method must have same name as in the parent class method must have same parameter as in the parent
class. must be IS-A relationship (inheritance).
Abstraction
Abstraction is a process of hiding the implementation details and showing only functionality to the user.
Another way, it shows only important things to the user and hides the internal details.
For example sending SMS, you just type the text and send the message. You don't know the internal processing about the message delivery.
Abstraction lets you focus on what the object does instead of how it does it.
Encapsulation
Encapsulation in java is a process of wrapping code and data together into a single unit, for example capsule i.e. mixed of several medicines.
We can create a fully encapsulated class in java by making all the data members of the class private.
Advantages: By providing only setter or getter method, you can
make the class read-only or write-only. It provides you the control over the data.
The Java Bean class is the example of fully encapsulated class.
MySQL
The most popular Open Source Relational SQL database management system.
One of the best RDBMS being used for developing web-based software applications.
Uses a standard form of the well-known SQL data language, works on many operating systems and with many languages including PHP, PERL, C, C++, JAVA, etc.
Online Exam
System