Java class 1

1,768 views

Published on

Published in: Technology, News & Politics
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,768
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
140
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Not just a programming language but a complete platformThe Programming language Java standard class libraries which provide Application Programming Interface and JVM together form JRE (Java Runtime Environment)JDK (Java development kit) provides all the needed support for software development in Java.
  • Need a diagram to show garbage collection
  • Need a diagram to show garbage collection
  • Java compilers convert your code from human readable Java source files to something called “bytecode” in the Java world. “Bytecode” is interpreted by a JVM, which operates much like a physical CPU might operate on machine code, to actually execute the compiled code. Performance - Java performance in generally second only to C/C++ in common language performance comparisons. In the Java programming language and environment, a just-in-time (JIT) compiler is a program that turns Java bytecode (a program that contains instructions that must be interpreted) into instructions that can be sent directly to the processor.The just-in-time compiler comes with the virtual machine and is used optionally. It compiles the bytecode into platform-specific executable code that is immediately executed
  • Java compilers convert your code from human readable Java source files to something called “bytecode” in the Java world. “Bytecode” is interpreted by a JVM, which operates much like a physical CPU might operate on machine code, to actually execute the compiled code. Performance - Java performance in generally second only to C/C++ in common language performance comparisons. In the Java programming language and environment, a just-in-time (JIT) compiler is a program that turns Java bytecode (a program that contains instructions that must be interpreted) into instructions that can be sent directly to the processor.The just-in-time compiler comes with the virtual machine and is used optionally. It compiles the bytecode into platform-specific executable code that is immediately executed
  • Adv. Question : What is the range of primitive data types ?Initalization:If no value is assigned prior to use, then the compiler will give an errorJava sets primitive variables to zero or false in the case of a boolean variableAll object references are initially set to null
  • Java provides six relational operators:greater than (>), less than (<), greater than or equal (>=), less than or equal (<=), equal (==), and not equal (!=).
  • Is it really needed to define all the types of operators.It will be better to show their differences through a program.
  • DemoBroke into multiple sentences
  • Java class 1

    1. 1. Java Review
    2. 2. What is Java ?• Java - Java is not just a programming language but it is a complete platform for object oriented programming.• JRE - Java standard class libraries which provide Application Programming Interface and JVM together form JRE (Java Runtime Environment).• JDK - JDK (Java development kit) provides all the needed support for software development in Java.
    3. 3. Java Virtual Machine (JVM)• Runs the Byte Code.• Makes Java platform independent.• Handles Memory Management.
    4. 4. Byte Code• Java bytecode is the form of instructions that the Java Virtual Machine executes• A Java programmer does not need to be aware of or understand Java bytecode at all.• The model of computation of Java bytecode is that of a stack oriented programming language.
    5. 5. Garbage Collection• The programmer is not responsible for memory management in Java.• The memory area in JVM where objects are created is called Heap.• The memory is freed during runtime by a special thread called Garbage Collector.• The GC looks for objects which are no longer needed by the program and destroys them.
    6. 6. Garbage Collection
    7. 7. Garbage Collection
    8. 8. Garbage Collection
    9. 9. Garbage Collection
    10. 10. How Java works ?• Java compilers convert your code from human readable to something called “bytecode” in the Java world.• “Bytecode” is interpreted by a JVM, which operates much like a physical CPU to actually execute the compiled code.• Just-in-time (JIT) compiler is a program that turns Java bytecode into instructions that can be sent directly to the processor.
    11. 11. How Java works ?
    12. 12. Basic Java Syntax
    13. 13. Data Types in Java• Data types define the nature of a value• We need different data-types to handle real-world information Name Size (in bits) Range long 64 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 int 32 –2,147,483,648 to 2,147,483,647 Short 16 –32,768 to 32,767 byte 8 –128 to 127 double 64 4.9e–324 to 1.8e+308 float 32 1.4e–045 to 3.4e+038 char 16 0 to 65,536 boolean ?? true/false
    14. 14. Primitive Types and Variables • boolean, char, byte, short, int, long, float, double etc. • These basic (or primitive) types are the only types that are not objects (due to performance issues). • This means that you don’t use the new operator to create a primitive variable.
    15. 15. Naming Convention of Variables• Can start with a letter, an underscore(_), or a dollar sign ($)• Cannot start with a number. long _LongNumber = 9999999; String firstName = “John”; float $Val = 2.3f; int i, index = 2; double gamma = 1.2; boolean value2 = false;
    16. 16. Statements & Blocks• A simple statement is a command terminated by a semi-colon: name = “Fred”;• A block is a compound statement enclosed in curly brackets: { name1 = “Fred”; name2 = “Bill”; }• Blocks may contain other blocks.
    17. 17. Flow of Control• Java executes one statement after the other in the order they are written.• Many Java statements are flow control statements: Alternation: if, if else, switch
    18. 18. Java Basic Constructs• If• If…else• Nested If…else• Switch Statement
    19. 19. If else– Syntaxif ( <condition> ){ // Execute these statements if <condition> is TRUE}
    20. 20. If else– Syntaxif ( <condition> ){ // Execute these statements if <condition> is TRUE}else{ // Execute these statements if < condition> is FALSE}
    21. 21. If else– Syntaxif ( <condition1> ){ // Execute these statements if <condition1> is TRUE} else if ( <condition2> ){ // Execute these statements if <condition2> is TRUE} else { // if both <condition1> and <condition2> is FALSE}
    22. 22. switch– Syntaxswitch (expression){case cond1: block_1; break;case cond2: block_2; break;...default: block_default;}
    23. 23. Operators• Provide a way to perform different operations on variables• Categories of Java Operators Assignment Operators = Arithmetic Operators - + * / % Relational Operators > < >= <= == != Logical Operators && || & | ^ Unary Operators + - ++ -- !
    24. 24. Assignment and Arithmetic Operators• Used to assign a value to a variable• Syntax – <variable> = <expression> Assignment Operator =• Java provides eight Arithmetic operators: – for addition, subtraction, multiplication, division, modulo (or remainder), increment (or add 1), decrement (or subtract 1), and negation.
    25. 25. Relational Operators• Used to compare two values.• Binary operators, and their operands are numeric expressions. Relational Operators > < >= <= == !=
    26. 26. Logical Operators• Return a true or false value based on the state of the variables• There are six logical operators Conditional AND Conditional OR AND OR NOT Exclusive OR Logical Operators && || & | ! ^
    27. 27. Static versus Non-static Variables• Static variables are shared across all the objects of a class – There is only one copy• Non-Static variables are not shared – There is a separate copy for each individual live object.• Static variables cannot be declared within a method.
    28. 28. •Q& A..?
    29. 29. Thanks..!

    ×