You are on page 1of 6

Java is used for big data it is open source

Java is an object oriented programming language


Object means which has state and behaviour
Computing platform of java was first released by Sun Microsystems in 1995
JVM is specifications or standards of java
Java was created by a team lead by James Gosling
Java is a platform independent language that follows the logic of "Write once , run
anywhere"
Eg: the code written in windows system can be run in linux as well
Unlike .net which requires microsoft stack implemented

Java Features

=>Simple
Java is easy to learn and its syntax is simple(verbose) You can just read it
through
clean, easy to understand.
The confusing and ambiguous concepts of C++ are either left out in java or they
have been
re-implemented in cleaner way.

=>High Performance
Although java is an interpreted language it is designed to support "just-in-time"
compilers, which dynamically compile bytecodes to machine code
If nothing works as expected in java we can raise a ticket and the oracle team will
go through it
if many tickets have been raised on same thing and will notify us in particular
release on
particular enhancement has been coming up if something can be done on that issue.
So if something doesn't work it will surely rectify in future releases.Its a High
performance language and always evolving

=>Secure
java can be used to develop virus-free systems
It is secured because it runs in machine sandbox to prevent any activity from
untrusted sources
No use of explicit pointers unlike C
As pointers locate the memory location no data manipulation malicious so they can't
change
the content in memory location

=>Robust
java checks the code during compilation time and run time
Compilation means if we have some syntactical errors then like missing : at the end
of the statement
then it will prompt us regarding the issue in compilation time and asks us to
correct it
Once everything is as expected then it will compile and create the class file
Java completely takes care of the memory allocation and releasing which makes java
more
robust unlike in other programming languages
Java by itself does garbage collection=> when a memory is not used by our program
it will clean
up by itself you don't need to write particularly a clean up code

=>portable
Applications written on one platform of java can be easily ported to another
platform as it
is platform independent
=>Dynamic
Many objects are evaluated at runtime and the execution is carried out not only
during compile time
Eg:Runtime Polymorphism

=>Distributed
RMI(Remote method invocation).EJB(Enterprise java beans) etc. are used for creating

distributed applications using java


Using this a program can call a method of another program running in some other
computers
the networks
This is one of the major features why java is been widely used in big data
Big data = We have chunks like data we get petabytes like data coming in every
minute
every hour or every day and we want to process it. But it cannot be done in one
machine
but on one server
These machines run on commodity hardware instead of server hardware or enterprice
level hardware which needs a lot of investment for companies

=>Multi-threaded
Thread is a task in a process/program
Multi-threading is multiple tasks running or executing at the same instance of time

We have 4 cores/processors in our machine


If we want to do add of two nums and mul of two nums then we don't need to use only
one core
to run everything
so we could run add on one core and mul on other simultaneously we don't have to do
that
in sequential manner Thats what multi-threading

=>Object oriented
Java is an ooLanguage. Everything is performed using "objects". Java can be easily
since it is based on the object model

=>Where is java used?


Android apps
Financial companies because it is secure
java web apps becoz it has lot of web servers supporting
Embedded systems =j2me which requires to be light weight
web servers and application servers
Enterprise applications
Scientific applications which requires high level of accuracy and precision
which requires lot of cpu time where java is good at
Bid data technologies
Internet of things(iot) = its connecting things together which emits data

Specifications exposed by java


j2me j2se j2ee

Java virtual machine(JVM)


Its a virtual machine that runs java bytecodes it is platform dependent for windows
and linux it has diff jvms
The JVM doesn't understand java source code, that is why we compile
our *.java files to obtain *.class files that contain the bytecodes understood by
jvm
The same bytecodes give the same results makes java a platform independent language
(wrte once Run anywhere)

Java code (.java) => Javac compiler =>Byte Code(.class) => JVM =>windows,ubuntu,mac
OS

Java Runtime Environment(JRE) =JVM +Set of libraries like (rt.jar)+Other Additional


files

The JRE does not contain tools and utilities such as compilers or debuggers for
developing applets and application

Jar =>Java archive which is a set of java classes or class files

rt.jar would have something like string class and other classes

Java Development kit(JDK)


JDK is a superset of JRE and contains everything that is in the JRE, plus tools
such as compilers and debuggers
necessary for developing applets and apps.
JDK = JRE + Developmenta tools(javac, java etc)

To just run a class file we need JRE but as developer we need JDK

Compile-time Environment

Java Source(.java)=>whatever we write as developer we get this file


|
Java Compiler
|
Java Bytecode(.class) code is syntactically correct as no errors were flagged
by compiler
(Java bytecodes move locally or through network or just put it in pendrive
and take it anywhere(platform independent))

PUBLIC keyword =>is an access modifier which represents visibility of class, it


means it is visible to all'
The "Hello World" can be publically seen anywhere in the application

Class keyword => is used to declare class in java

HelloWorld => is name of the class

public static void main =>entry point for our application/class file

Static => To declare any method as static , the main adv of static method is there
is no need to create object to
invoke the static method. We need not create instance

void =>is the return type of the method, it means it doesn't return any value

main=>represents startup of program

String[] args => used for command line argument we can give as many strings as we
want

jshell = >its not for production use just to test what can be the output for
particular command would be
MODIFIERS => is a word or phrase or clause that describes and changes or modifies
the meaning of another word or phrase in some way like (public, private )
Eg: policeman , traffic policeman
traffic is the modifier
Modifiers
/ \
Access Non-access

Access control modifiers =>(this is what drives the encapsulation factor of object
oriented paradigm)
We control the access of all these components that means encapsulated
Java provides a number of access control modifiers to set access level for classes,
variables,methods,constructors
The 4 access levels are-
1)Default =>Visible to package(com.edureka)= without any access modifier
package com.edureka

classs helloworld(){
}

2)Private =>Visible to the class only= has lowest visibility


3)Public =>Visible to the world
4)Proteted =>Visible to the package and all subclasses(inherited)

Non-Access Modifiers
Java privides a no. of non-access modifiers to provide additional functionalities
to a class, variable,method,
constructor
1)Static: the static modifier for calling methods and variables without aan
object to which it belongs

2)Final: for finalizing the implementations of classes,methods, and variables


we can't change it once it is created. This is good enough for the constants
so that no one can change it

3)Abstract : used for creating abstract classes and methods


when we want to ensure that the subclass of the shapeclass implements the area
thats when we create it as abstract
The shape class would have area method as abstract which would be implemented by
the subclasses
If the subclasses won't implement it we will get error
Area is an abstract method for sub class
sqaure=s^2
rec=l*b

4)Synchronised and volatile: are used for threads


Only one thread would get access at one point
If it is multithreading then only one thread will access it and other threads have
to wait
Volatile=>don't store it in cache store it directly into the main memory
When we use synchronised we don't use volatile it is mutually exclusive

Variables

These are memory locations which are reserved to store values means while declaring
a variable
we reserve memory
There are 3 types of variables
Variables
/ | \
local instance class/static

1) Local :local to our method it has only local scope not accessible out of the
method it was created in
This is where garbage collection for java is useful once we loose control out of
the method then garbage
will kick in and clean up the variable/memory location
=>Local vars are declared in methods,contstructors,or blocks and are visible only
in these 3
=>These are created when execution enters a these 3
These are implemented at stack level internally
There is no default value for local variables, so local variables should be
declared and an initial
value should be assigned before the first use

2) Instance = something that is defined at instance level


these are declared in class
when a space is allocated for an object in the heap, a slot for each instance
variable value is created
Instance variables are created when an object is created with the use of the
keyword "new" and destroyed
when the object is destroyed
Access modifiers can be given for instance variables
These are visible for all methods, constructors and block in the class
Instance variables have default valuess. For numbers, the default value is 0, for
booleans it is false,
and for object reference it is null
Values can be assigned during the declaration or within the constructor
Instance variables can be accessed directly by calling the variable name inside the
class. However,
within static methods( where instance variables are given accessibility) they
should be called using
the fully qualified name ObjectReference.VariableName

3)Class variables are declared with the static keyword inside a class, but it is
created outside a
method, constructor or a block
Class variables are declared as constants i.e. variables never change from their
initial value
Static variables are stored in the static memory
It is rare to use static variables other than declared final and used as either
public or
private constants
Created when the program starts and destroyed when the program stops
Static vars are declared public since they must be available for users of the class
Static vars can be accessed by calling with the class name - ClassName.VariableName
Instance is one per object and staic is one per class

You might also like