Professional Documents
Culture Documents
1.
Java is a general-purpose high-level object programming language that provides the following characteristics: Simple Object Oriented Interpreted Architecture-Neutral Platform Independent Multithread Dynamic High-Performance Distributes Robust Secure
Usually, a programming language requires either a compiler or an interpreter to translate a code written in high-level programming language (source code) into its machine language (object code) equivalent. But, to run a Java Program, Java uses a combination of compiler and interpreter. The compiler translates the Java program into an intermediate code called Java byte code. Java interpreter is used to run the compiled Java Byte Code. This allows Java Programs to be executed on different platforms.
Java source code (Sample.java ) Compile r Java byte code (Sample.class) Interprete r Object Code
2.
Java as a Platform
A software and/or hardware environment in which a program runs is referred to as a platform. The Java platform is a software that is compatible with and/ or executes on platform based on different hardwares. The Java runtime environment is shown below: Source Code
Object Code
Operating System
HOST
Byte Code
LOCAL
Machine Language
JVM Interpreter
In C 4. Java Shows High Performance. Java performance is impressive for an interpreted language, mainly due to the use of intermediate byte code. Javas architecture is designed to reduce overheads during runtime. Incorporation of multi-threading enhances the overall execution speed of Java programs. 5. Java is Compiled and Interpreted. The Java programs are first compiled and then interpreted. While compiling, the compiler checks for the errors in the program and list them all on the screen. After error-correction,
Keywords: Programming languages have certain words, usually termed reserved words or keywords, that convey special meanings to the compiler. These keywords can be used only for their intended action and they cannot be used for any other purpose.
1.2.2 Literals
A literal denotes constant value. This implies that 0 (zero) is an integer literal and c is a character literal. Reserved literals true and false are used to represent boolean literals. A simple Java program is a string literal. In addition there is the null literal (null) which represents the null reference. Integer Literals: primary literals used in Java programming. Integer literals can be of decimal, hexadecimal and octal formats. Floating-point literals: represent decimal numbers with fractional parts, such as 3.145. They can be expressed in either standard or scientific notation, meaning that the number 563.84 can also be expressed as 5.6384e2. Boolean Literals: commonly used in Java programming, present in almost every type of control structure. Boolean literals are needed to represent a condition or state that has only two possible values. Boolean values can be denoted using the reserved literals true or false. Character Literals: Unicode is a universal character encoding representation. It uses two bytes (16-bit character set) and also represents all international languages as character sets in Java. String Literal: is a sequence of characters, that are given within quotation marks and must occur on a single line.
1.2.4 Comments
A program can be documented by inserting comments at relevant places. The Java compiler ignores these comments. Java provides three types of comments: Single line comments: All characters that follow // until end of the line constitute a single line comment. For example: // This comment ends at the end of this line. Multiple line comments: A multiple line comment can spanseveral lines. Such a comment starts with /* and ends with */. For example: /* A comment on several lines */ Documentation Comment: A documentation comment is a special purpose comment which when placed at appropriate places in the program can be extracted and used by the javadoc utility to generate HTML documentation for the program. Documentation comments are usually placed in front of class, interface, method, and variable definitions. Groups of
The eight primitive data types can further be grouped in the following categories:
1.3.1.1
Integer Type
1.3.1.2
Character Type
Character data type can store symbols, such as letters and numbers. In Java, the character data type is represented by char. The char data type represents symbols in the unicode character set, such as letters, digits, and special characters. It encompasses all the 65536 (216) characters in the Unicode character set which are written in the form of 16 bit values. The first 128 characters of the Unicode set (0 127) are the same as the 128 characters of the 7 bit ASCII character set, and the first 256 characters of the Unicode set (0 - 255) correspond to the 256 characters of the 8 bit ISO Latin-I character set.
1.3.1.3
Floating point data type can store fractional numbers. This category includes the data types float and double. Examples of these are the following: float pi = 3.14159F double p = 313.159e-2 double fraction = 1.0/3.0
1.3.1.4
Boolean Type
Boolean data types is used to represent logical values that can be either true or false. All relational, conditional, and logical operators return boolean values. They are primarily used to keep track of the flow during program execution. Boolean values cannot be converted to other primitive data types, and vice versa. Primitive data values are atomic and are not objects. Each primitive data type defines the range of values in the data type and special operators Note: The groups, Integer and Floating point can store negative values. Java, unlike C/C++, does not support the concept of unsigned integers.
*Further do it yourself
10