java class1

20
JAVA DAY 1 TRANING --By PRUDHVI AKELLA

Upload: prudhvi-akella

Post on 18-Jul-2015

46 views

Category:

Technology


0 download

TRANSCRIPT

JAVA DAY 1 TRANING

--ByPRUDHVI AKELLA

Source code(.java) Javac(java compiler) .class file(intermediate code or byte

code)

JVM(java virtual

machine)

JVM is different for each OS(Linux, windows)Where jvm will convert any byte code into machine code. that's why java is called as

platform independent.

Machine codeProcessor

Memory Management

Processor

Processor will create memory for JVM

JVM

1).Jvm will use that part of

limited memory to create

objects, which is created by

Processor

2).So as the memory is limited and filled soon.so when object is no

longer used by program memory will be destroyed

by a Garbage Collector (GC) it is

special Thread.

3) Memory where JVM creates an

object called HeapGC Thread is also

called as Demon Thread.

What function can call Garbage collector?

Runtime.gc();

How Memory will be Destroyed By GC?

object

reference

HEAP

object

reference

HEAP

Cloud Represents The HEAP Memory created by processor for JVMFigure1 show the link between the reference and object

Figure2 shows link got destroyed between reference and object.When There is no link between Object and reference The GC will destroy the memory for

reference and object(shown in figure3)

object

reference

HEAP

How java works?

• When java source code is converted as .class(byte code) file by compiler.• The byte code moves through network or local host.

• The class loader loads the byte code into JVM.• The byte code verifier contains some predefined format . if the byte code is not in that

format it throws and error.• The interpreter interprets the Byte code into machine(it will execute line by line).the main

use of just in time compiler is if interpreter find repeated code(for example 10) it will pass those lines of code to complier it will execute and store it in cache memory when

interpreter again encounters the redundant code then I will directly fetch instructions from cache(fastest memory and temporary memory). This way process will become faster

Interpreter

JIT(just in time compiler)

Cache memory

Code lines

Green lines are the normal code lines.

Orange lines are the repeated code lines.

Path 1 is when interpreter find t he repeated code for first

time.Path 2 is when interpreter find

the code for second time.

1 1

12

2

1

2

Date Types in java(data types defines the nature of the value).

Primitive types and variables and naming convention(java is not a purely object oriented programing due to primitive data types in java).

Statement and Blocks.

Flow of Control.

IF_ELSE syntax

NESTED if_else syntax

Switch case syntax

Operators

Assignment and Athematic Operator

Relational Operator

Logical Operator

Logical Operator

Static Variables VS dynamic Varibles

Static Variables Example

package pratice;

public class Pratice {

static int preatice = 12;

public static void main(String[] args) {

classs1s obj = new classs1s();obj.fun();

}}

public class classs1s {void fun(){

System.out.println(Pratice.preatice);Pratice.preatice = 20;System.out.println(Pratice.preatice);

} }