Introduction To Programming Languages PDF Download
Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java platform (Java 1.0 [J2SE]).As of December 2008, the latest release of the Java Standard Edition is 6 (J2SE). With the advancement of Java and its widespread popularity, multiple configurations were built to suite various types of platforms. Ex: J2EE for Enterprise Applications, J2ME for Mobile Applications. Sun Microsystems has renamed the new J2 versions as Java SE, Java EE and Java ME respectively. Java is guaranteed to be Write Once, Run Anywhere. Java is:
· Object Oriented: In Java, everything is an Object. Java can be easily extended since it is
based on the Object model.
· Platform independent: Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run.
· Simple: Java is designed to be easy to learn. If you understand the basic concept of OOP Java would be easy to master.
·Secure: With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption.
· Architectural-neutral :Java compiler generates an architecture-neutral object file format which makes the compiled code to be executable on many processors, with the presence of Java runtime system.
· Portable: Being architectural-neutral and having no implementation dependent aspects of the specification makes Java portable. Compiler in Java is written in ANSI C with a clean portability boundary which is a POSIX subset.
· Robust: Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.
· Multithreaded: With Java's multithreaded feature it is possible to write programs that can do many tasks simultaneously. This design feature allows developers to construct smoothly running interactive applications.
· Interpreted: Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The development process is more rapid and analytical since the linking is an incremental and light weight process.
· High Performance: With the use of Just-In-Time compilers, Java enables high performance.
· Distributed: Java is designed for the distributed environment of the internet.
· Dynamic: Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.
Token:- The smallest individual unit in a program is known as Token. Java has the following
types of tokens:-Keyword ,Identifier, Literals, Punctuators and operators.
Keywords:-The following list shows the reserved words in Java. These reserved words may not
be used as constant or variable or any other identifier names.
A literal is a source code representation of a fixed value. They are represented directly in the code without any computation. Literals can be assigned to any primitive type variable. For example:
byte, int, long, and short can be expressed in decimal(base 10), hexadecimal(base 16) or octal(base 8) number systems as well. Prefix 0 is used to indicate octal and prefix 0x indicates hexadecimal when using these number systems for literals. For example:
String literals in Java are specified like they are in most other languages by enclosing a sequence of characters between a pair of double quotes. Examples of string literals are:
String and char types of literals can contain any Unicode characters. For example:
All Java components require names. Names used for classes, variables and methods are called identifiers. In Java, there are several points to remember about identifiers. They are as follows:
· All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an
· After the first character identifiers can have any combination of characters.
· A key word cannot be used as an identifier.
· Most importantly identifiers are case sensitive.
· Examples of legal identifiers: age, $ salary, _value, __1_value
· Examples of illegal identifiers: 123abc, -salary
Java provides a rich set of operators to manipulate variables. We can divide all the Java operators
into the following groups:
· Arithmetic Operators · Relational Operators
· Bitwise Operators
· Logical Operators
· Assignment Operators
· Misc Operators
Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra. The following table lists the arithmetic operators: Assume integer variable A holds 10 and variable B holds 20, then:
There are following relational operators supported by Java language Assume variable A holds 10 and variable B holds 20, then:
The following table lists the logical operators: Assume Boolean variables A holds true and variable B holds false, then:
There are following assignment operators supported by Java language:
There are few other operators supported by Java Language.
Conditional Operator ( ? : ) :- Conditional operator is also known as the ternary operator. This operator consists of three operands and is used to evaluate Boolean expressions. The goal of the operator is to decide which value should be assigned to the variable. The operator is written as:
Following is the example:
This would produce the following result:
Please send your queries to email@example.com you can aslo visit our facebook page to get quick help. Link of our facebook page is given in sidebar
Copyright @ ncerthelp.com A free educational website for CBSE, ICSE and UP board.