×
☰ See All Chapters

Buzzwords of Java

buzzwords-of-java-0
 

The inventors of Java wanted to design a language which could offer solutions to some of the problems encountered in modern programming. They wanted the language to be not only reliable, portable and distributed but also simple, compact and interactive.  The authors of Java have written an influential White Paper that explains the features of java by all of the following buzzwords:

  • Simple  

  • Object Oriented  

  • Platform Independent 

  • Distributed  

  • Robust  

  • Secure  

  • Architecture Neutral 

  • Portable 

  • Interpreted 

  • High Performance 

  • Multithreaded 

  • Dynamic 

Simple

Java is an object-oriented programming language with syntax and keywords almost identical to C++. When developing Java, its creators took all of the good features of the existing object-oriented programming languages such as C++, Ada, and Smalltalk, and removed most of their flaws and peculiarities. There are a lot of aspects of the Java language that are consistent and make sense, thereby making it easier to learn.

If you are familiar with C++ you would know about clumsy features of C++: header files, pointer arithmetic (or even pointer syntax), structures, unions, operator overloading, virtual base classes, and so on. All these clumsy features are cleaned-up in java making it easier to learn.

Object Oriented

What is object oriented programming (OOP) language?

Any programming language if supports Encapsulation, Abstraction, Inheritance, Polymorphism then that language is an object oriented programming language. E.g. java, C++

Define OOP concepts?

If you have just started learning java, definitely it is very hard to understand the Object oriented programming (OOP) concepts. Once you learn java completely then you will understand these concepts. Many java professional who are using these concepts in their daily life will fail to define OOP (Object Oriented Programing) concepts. Below are the definitions of OOP concepts which will surely help you when you are attending the java interviews.

Encapsulation: It is the Process of binding the data and methods together into a single unit. Example: Binding private variables with setter and getter methods.

Abstraction:  Showing Essential properties and methods of an object by hiding internal things is called as Abstraction. Abstraction is possible if and only if there is encapsulation. Example: Java is an abstraction layer over binary language. Hibernate is an abstraction layer over JDBC

Inheritance: Inheriting the properties and methods of one class (super class) into another class (sub class) using IS a relationship. Example: Ferrari class inherits the features of Car class. Puppy class inherit the features of Dog class, Dog class inherit the features of Animal class

Polymorphism: One form behaving differently in different situations is called polymorphism. Animal class behaving differently for different objects like Dog, Cat etc...

Platform independent

Java can run in any system line windows, Linux, mac etc.  You no need to write separate program for individual platform/OS. Program written in Windows platform can run in Linux platform. Output of java compiler (javac.exe in windows) is a bytecode (.calss file), but not native machine code. This bytecode is interpreted by virtual machine (not by real computer) as real computer interprets .exe files in C/C++.  Such a virtual machine is called as Java Virtual Machine (JVM).

Translating java program into Byte code makes it much easier to run a program in wide variety of platforms/Environments, because only JVM need to be implemented. Once bytecode is ready, we can run it in windows, Linux, calculator, mobile, watch etc.., but one thing is all environments require just JVM. Details of JVM differ from environment to environment. (Platform to Platform)

buzzwords-of-java-1
 

Distributed

  • A technology is said to be distributed if it's business objects are geographically dispersed into different locations and still communicating one another.   

  • Networking capabilities of java are strong and easy to use. 

  • Onerous tasks like opening a socket connection are simple in Java. 

  • An elegant mechanism, called servlets, makes server-side processing in Java extremely efficient. Many popular web servers support servlets. 

Robust

Programming language is robust when it is reliable and strong. Below capabilities make java robust:

  • Java has a garbage collector which will automatically clean up unused objects and memory. No need to chase memory corruption. 

  • In java you do not use pointers to access strings, arrays, objects, even files. Nor do you need to worry about memory allocation for them. 

  • Java has exception handling mechanism which is very useful in handling both compile and run time errors. Without handling errors and exceptions, entire application would fail. With exception handling it just stops the current flows even that are when failed, but rest all flows still runs. 

Secure

Java team has said that they will have a “zero tolerance” for security bugs and will immediately go to work on fixing any bugs found. Java program will be first compiled to byte code. This byte code will then be interpreted by Java Virtual Machine (JVM). JVM makes java secure with below factors:  

  • JVM will not overrun the runtime stack. 

  • JVM will not corrupt memory outside its own process space. 

  • JVM will not read or write to local files when invoked through a security-conscious class loader. 

Architecture Neutral

The compiler generates architecture-neutral bytecode instructions which have nothing to do with particular computer architecture. These bytecode instructions can be run by only JVM. JVM is not same for platforms and architectures. Java will provide you different JVMs for different platforms and architectures. So you just have to install different JVMs. A bytecode once ready can be run by any JVM.

A program written in 32 bit operating system can be run by JVM in 64 bit operating system.

Portable

In C/C++ data size varies from platform to platform. For example integer can be a 16-bit integer, a 32-bit integer, or any other size that the compiler vendor likes. In java has a fixed size for data that eliminates a major porting headache. Binary data is stored and transmitted in a fixed format, eliminating the “big endian/little endian” confusion. Strings are saved in a standard Unicode format.  Java does this by JVM. Java facilitates you to carry the Java bytecode to any platform. It doesn't require write different program for different platforms line windows, Linux etc…

Interpreted

Java Virtual Machine (JVM) is the java interpreter. The interpreter can execute Java bytecodes directly on any machine to which the interpreter has been ported.  Since installing JVM is a lightweight process, the development process can be much more rapid and exploratory.

High Performance

When Java was still a new language, it was criticized for being slow: Since Java bytecode was executed by an interpreter, it seemed that Java bytecode programs could never run as quickly as programs compiled into native machine language (that is, the actual machine language of the computer on which the program is running). However, this problem has been largely overcome by the use of just-in-time compilers (JIT) for executing Java bytecode.

JIT is a part of JVM. A just-in-time compiler translates Java bytecode into native machine language. It does this while it is executing the program. Just as for a normal interpreter, the input to a just-in-time compiler is a Java bytecode program, and its task is to execute that program.

It is important to understand that it is not practical to compile an entire Java program into executable code all at once, because Java performs various run-time checks that can be done only at run time. Instead, a JIT compiler compiles code as it is needed, during execution. Furthermore, not all sequences of bytecode are compiled—only those that will benefit from compilation. The remaining code is simply interpreted. The translated parts of the program can then be executed much more quickly than they could be interpreted. Since a given part of a program is often executed many times as the program runs, a just-in-time compiler can significantly speed up the overall execution time.

Even though dynamic compilation is applied to bytecode, the portability and safety features still apply, because the JVM is still in charge of the execution environment.

Multithreaded

thread is defined as a separate path of execution inside any process. It is done to use CPU idle time. A process consists of the memory space allocated by the operating system that can contain one or more threads. A thread cannot exist on its own; it must be a part of a process. Whenever a thread is created within a program it will not occupy any separate space. It will share the same memory space of the program. It will also not consume more resources.

Thread implementations on the major platforms differ widely, but Java makes no effort to be platform independent in this regard. Only the code for calling multithreading remains the same across machines; Java offloads the implementation of multithreading to the underlying operating system or a thread library.

Dynamic

In a number of ways, Java is a more dynamic language than C or C++. It was designed to adapt to an evolving environment. Libraries can freely add new methods and instance variables without any effect on their clients. In Java, finding out run time type information is straightforward. This is an important feature in those situations where code needs to be added to a running program.


All Chapters
Author