BIIT

Java Programming Language

Unit I

JAVA is a computer known language that was developed by Sun Microsystems Inc. in the year 1991. After some time it was acquired by Oracle Corporation. It was developed by James Gosling and Patrick Naughton. It is a simple programming language. Java makes writing, compiling, and debugging programming easy. It helps to create reusable code and modular programs. Java is a class-based, object-oriented programming language and is designed to have as few implementation dependencies as possible.
It is used for:
a. Mobile applications (specially Android apps)
b. Desktop applications
c. Web applications
d. Web servers and application servers
e. Games
f. Database connection
And much, much more!
There is given many features of java. They are also known as java buzzwords. The Java Features given below are simple and easy to understand.
  1. Simple
  2. Object Oriented
  3. Plateform Independent
  4. Secured
  5. Robust
  6. Architecture Neutral
  7. Portable
  8. High Performance
  9. Distributed
  10. Multi Threading
Simple
1. it omits many rarely used, poorly understood, confusing features of C++, like operator overloading, multiple inheritance, automatic coercions, etc.
2. it contains no goto statement, but break and continue.
3. it has no header files and eliminated C preprocessor.
4. it eliminates much redundancy (e.g. no structs, unions, or functions).
5. it has no pointers.
6. it has some added features to simplify.
7. it has garbage collection, so the programmer won't have to worry about storage management, which leads to fewer bugs.
Object-oriented
Object-oriented means we organize our software as a combination of different types of objects that incorporates both data and behaviour. Object-oriented programming (OOPs) is a methodology that simplify software development and maintenance by providing some rules.
Basic concepts of OOPs are:.
1. Encapsulation.
2. Inheritance.
3. Polymorphism.
4. Abstraction.
5. Message Passing.
6. Dyanamic Binding.
7. Data hiding.
Platform Independent
A platform is the hardware or software environment in which a program runs. There are two types of platforms software-based and hardware-based. Java provides software-based platform. The Java platform differs from most other platforms in the sense that it's a software-based platform that runs on top of other hardware-based platforms.
It has two components:
1. Runtime Environment.
2. API(Application Programming Interface).
Java code can be run on multiple platforms e.g.Windows, Linux, Sun Solaris, Mac/OS etc. Java code is compiled by the compiler and converted into bytecode. This bytecode is a platform independent code because it can be run on multiple platforms i.e. Write Once and Run Anywhere(WORA).
Secured
Java is secured because:
1. No explicit pointer
2. Programs run inside virtual machine sandbox.

Robust
Robust simply means strong. Java uses strong memory management. There is a lack of pointers that avoids security problem. There is automatic garbage collection in java. There is exception handling and type checking mechanism in java. All these points make java robust.
Architecture-neutral
There is no implementation dependent features e.g. size of primitive types is set.
Portable
We may carry the java bytecode to any platform.
High-performance
Java is faster than traditional interpretation since byte code is "close" to native code still somewhat slower than a compiled language (e.g., C++)
Distributed
We can create distributed applications in java. RMI and EJB are used for creating distributed applications. We may access files by calling the methods from any machine on the internet.
Multi-threaded
A thread is like a separate program, executing concurrently. We can write Java programs that deal with many tasks at once by defining multiple threads. The main advantage of multi-threading is that it shares the same memory. Threads are important for multi-media, Web applications etc.
To learn Java Language we must learn about following:
Java Character Set
Java Token
Java Instruction/Statement
Java Program
Java Character Set: Like every other language, 'Java' also has its own character set. The Java character set consists of upper and lowercase alphabets, digits, special characters and white spaces. The alphabets and digits are altogether called as the alphanumeric character.
English Alphabet: a to z, A to Z.
Digits: 0 to 9.
Special Symbols: # + _ - * ! ~ & %........etc.
White Spaces: tab, enter, spacebar.
Java Tokens: Token is the smallest unit in a 'Java' program. It is each and every word and punctuation that you come across in your Java program. The compiler breaks a program into the smallest possible units (tokens) and proceeds to the various stages of the compilation. Every token must follow the rules defined below:
1. It must be a meaningful word.
2. Only english alphabets allowed to form a Java Token.
3. No special symbol except underscore(_) and doller symbol($) is allowed.
4. No White spaces are allowed.
4. Digits can be inserted but no token will be started with digit.
Types of Tokens
A token is divided into four different types:
1. Identifiers
2. Variables
3. Literals (Constants)
4. Keywords
1. Identifier: A token, which is used to identify something, is known as identifier. An identifier can be used for the name of Variable/ Constant/ Keyword/ Methods/ Class etc.
2. Variable: An identifier, for that values can be changed any time during the execution of program, is known as Variable.
3. Literal: An identifier, for that values can’t be changed throughout whole program, is known as Literal or Constant.
4. Keywords: An identifier, that has its specific meaning and can be used to perform some specific task, is known as Keyword. A keyword is a reserved word.
There are 49 keywords used in Java Language:
Note: an identifier can be used as a Keyword but not Vice-Versa.
Java Instructions/Statements: A meaningful collection of Java Tokens is called as Java Statements. Every instruction is used to instruct the Computer. Every instruction is ended with semicolon (;).
There are 3 types of instructions used in Java Language:
1. Type Declaration Instruction: To declare the type of variables used in a C Program.
2. Arithmetic Instruction: To perform arithmetic operations between constants and variables.
3. Control Instruction: To control the sequence of execution of various statements in a C Program.
Java Program: A meaningful set of Java Instructions is known as C Program. Every program is developed for performing a specific task. A set of programs is known as software.
Comments:A comment is an explanation or description of the source code of the program. It helps a developer explain logic of the code and improves program readability. At run-time, a comment is ignored by the compiler.
There are two types of comments in Java:
1) Multi-line Comment: A comment that starts with a /* and finishes with */ is known as Multi-line Comment. You can place it anywhere in your code, on the same line or several lines.
2) Single-line Comments: A comment that is started with // is known as Single-line comment.
3) Documentation Comments: A comment that is started with /** and finishes with */ is known as Documentation comment.

To be continued.........