introduction to java

165 views
106 views

Published on

basic concepts of java

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
165
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

introduction to java

  1. 1. Java Virtual Machine and Runtime Environment
  2. 2. Basic Concept  When you write a program in C++ it is known as source code.  The C++ compiler converts this source code into the machine code of underlying system (e.g. Windows)  If you want to run that code on Linux you need to recompile it with a Linux based compiler.  Due to the difference in compilers, sometimes you need to modify your code.
  3. 3. The Concept of WORA  Java introduced WORA: Write Once Run Anywhere  When you write a java program it is known as the source code of java.  The java compiler compiles this source code for a software system known as JVM  This compiled code is known as ‘Byte Code’  We have different JVMs for different systems (such as JVM for Windows , JVM for Linux etc).  When we run our program the JVM interprets translates) the compiled program into the language understood by the underlying system.  So we write our code once and the JVM runs it everywhere according to the underlying system.
  4. 4. Byte Code  Java programs (Source code) are compiled into a form called Java bytecodes.  The Java compiler reads Java language source (.java) files, translates the source into Java bytecodes, and places the bytecodes into class (.class) files.  The compiler generates one class file for each class contained in java source file.
  5. 5. Java Virtual Machine  The central part of java platform is java virtual machine  Java bytecode executes by special software known as a "virtual machine".  Most programming languages compile source code directly into machine code, suitable for execution  The difference with Java is that it uses bytecode - a special type of machine code.  The JVM executes Java bytecodes, so Java bytecodes can be thought of as the machine language of the JVM.
  6. 6. Java Virtual Machine
  7. 7. Java Runtime Environment(JRE)  The Java Virtual Machine is a part of a large system i.e. Java Runtime Environment(JRE).  Each operating system and CPU architecture requires different JRE.  The JRE consists of set of built- in classes, as well as a JVM.  Without an available JRE for a given environment, it is impossible to run Java software.
  8. 8. Java Runtime Environment
  9. 9. First Java Program
  10. 10. Data Types  The Java programming language is strongly-typed, which means that all variables must first be declared before they can be used. int gear = 1;  The eight primitive data types supported by the Java programming language are: – int, byte, short, long, float, double, boolean, char
  11. 11. Naming Conventions  Java uses identifiers to name – variables – methods – classes – packages  Syntax rules – Must begin with a letter (upper- or lower-case) – May be followed by any number (including 0) of letters and digits – The characters $ and _ are considered letters – Java identifier names are case sensitive – May not duplicate a Java keyword (e.g. class or main)
  12. 12. Escape Sequence
  13. 13. Control Structures  Loops: for, while, do while  If, if else, if else if, switch case
  14. 14. Class and object  Class is a user defined data type.  Object is variable of a class – Data Members and Methods  Constructor  Method Overloading  Inheritance  Method Overriding

×