Topics

6/recent/ticker-posts

Introduction to JAVA

                             Java Introduction


JAVA: A simple, object oriented, distributed, interpreted, robust, secure, architecture neutral,
            portable, high performance, multithreaded, dynamic language.

for java classes online refer to the below given link:

Link for Course

And for contacting instructor refer click the link given above

Its features:

I. Simple

ii. Secure

iii. Portable (Compiled and Interpreted/Platform independent)

iv. Robust

v. Multithreaded

vi. Distributed

vii. Architecture Neutral

viii. Object Oriented

1.Simple

    Java Programming Language is simple but vast. Vast because so many libraries are given

which are suitable to build business applications. C++ supports pointers, but java eliminated

accessing of pointers in the program but it internally uses pointers. C++ program most employs

operators to write statements. Whereas Java mostly employs keywords to write programming

hence it is developer friendly. Some of the C++ concepts which are felt unwanted, not secure

are also eliminated in Java programming language such as pointers (ease of programming,

security not to access memory addresses), multiple inheritance (reduces complexity of

hierarchy, super class variables and methods ambiguity), operator overloading (not necessary,

only + symbol is overloaded for string concatenation), friendly inheritance, enums, typedefs,

unions. Along with all these java recommended a programming convention called Camel Case

Convention.

to declare class – idontknowwhatmyclassnameis looks confusing hence use UPPERCASE letter

for every word starting letter as IDontKnowWhatMyClassNameIs.

to declare variables - myAgeIs;

to declare method - calEmployeeSalariesAndDeductions()

to declare method - cal_employee_salaries_and_deductions()

2.Secure

Elimination of pointers. Java doesn’t allow us to get the memory address of any variable called

as pointer. This is how java programs are secure and another concept in java is we can develop

two types of programs called standalone programs and Applets. When java program is loaded

into JVM (the JVM is launched by java.exe command), the class is loaded into ClassLoader

first, there our .class file and all the classes used in our program are all loaded at runtime into

our VM ClassLoader, next byte code verifier will execute. Byte code verifier will verify the

statements written in the program (such as var management, conditions, loops, accessing files,

sockets, DB etc) against with two files called java.policy and java.security. These two files exist

in JDK\jre\lib\security folder. In that file we can grant or deny permissions to standalone

programs or Applets downloaded and running on our system. Based on the permission the byte

code verifies allows/deny our program to go to interpreter for execution.


3.Portable

Compiled programming languages are all platform dependent.

Compiled & interpreted programming languages are platform independent.

Interpreted programming languages are also a platform independent.

Coming Java, Java programs are platform independent, javac and java (JVM launcher-

ClassLoader, Byte Code Verifier and Interpreter) are platform dependent. That means javac

written seperately for each OS (Windows, Unix, Solaris, Mac, OS/400, OS/2) but the compiler

compiled source code into byte code is independent of OS because the byte code instructions

are java byte code instructions which are identical to processor instructions but java speicific

instruction. These instructions are read by java interpreter (java.exe), java interpreter is also

written seperately for every OS, but all java interpreter understand the same byte code

instructions and converts those instructions into processor specific instructions.

Object Oriented:
E A I P MP - Encapsulation, Abstraction, Inheritance, Polymorphism, Message Passing.

Encapsulation: 

Hides the data members/variables of a class and exposes them through public setter and getter

methods. For instance we want to develop a class that expose Employee details to client by

only taking eid as input, so that we will declare Employee class variables eid, ename, sal, desig

as private and through public setter method for eid and getter methods for ename, sal and desig

we will expose the emp data to client. Others can only access emp details but cannot be

modified. Through Encapsulation we allowed used to only set eid and through getter methods ename, sal,

and desig can be accessed. Client cannot modify ename, sal & desig.

Abstraction:

Hides the behavior/method implementations from its behavior/method. Exposing only method

names to client and hides its implementation details.

Inheritance:

Allows its data/variables and behaviors/methods reusable to their sub classes.

Polymorphism:

Writing same method many times in a class with different method signature is called as Method

overloading. Rewriting super class method in sub class with the same signature is called as Method overriding.

Robust:

The general meaning of Robust is tough. Java as a Robust can be viewed from different

perspectives. In some languages if we write a program to read data from the file, if file doesn't

exist in the required folder, some language cannot handle the situation, if we write something

divided by zero, languages cannot handle the situation. But in java for every abnormal condition

the JVM is developed in such a that JVM raises an exception, describes the exception detail

and can give the control to the programmer to handle the situation whether to continue or

terminate the program from execution. System crash doesn't happen with Java programming.

Another perspective of Robust is in java there is a automatic memory management and garbage

collection feature. This feature de-allocates the variables which are no longer in use in the java

programming.

Multithreaded:

Multithreading features allows us to run more than one method concurrently. If this feature

doesn't exist methods can run sequential in the program. That means more than one method

can run at a time, such as one method calculate employee salary, one method can print emp

salary. If multithreading concept doesn't exist we need to calculate all these employee’s salary

before printing employee payslips. This slows down the emp payroll process.

Distributed:

Because of java programming language supports distributed programming we can invoke java

methods from remote systems which are very much useful in business applications. Business

applications such as online ticket booking. In the online ticket booking the booking database

exist in one machine, the bank & credit card applications runs on different machines. Then how

these applications communicate from one machine to another machine, one machine

implemented method accessed from another machine is because of distributed programming

suport. Internally distributed programming feature uses Socket programming. To develop

distributed applications we will use RMI, CORBA, EJB and WebServices.

Architecture Neutral:

With architecture-neutral, the book means that the byte code is independent of the underlying

platform that the program is running on. For example, it doesn't matter if your operating system

is 32-bit or 64-bit, the Java byte code is exactly the same. You don't have to recompile your

Java source code for 32-bit or 64-bit. (So, "architecture" refers to the CPU architecture).

"Portable" means that a program written to run on one operating system works on another

operating system without changing anything. With Java, you don't even have to recompile the

source code; a *.class file compiled on Windows, for example, works on Linux, Mac OS X or any

other OS for which you have a Java virtual machine available.

Post a Comment

0 Comments