See the Tutorial List

Features of Java

The prime reason behind creation of Java was to bring portability and security feature into a computer language. Beside these two major features, there were many other features that played an important role in moulding out the final form of this outstanding language. Those features are :


1) Simple

Java is easy to learn and its syntax is quite simple, clean and easy to understand.The confusing and ambiguous concepts of C++ are either left out in Java or they have been re-implemented in a cleaner way.

Eg : Pointers and Operator Overloading are not there in java but were an important part of C++.


2) Object Oriented

In java, everything is an object which has some data and behaviour. Java can be easily extended as it is based on Object Model. Following are some basic concept of OOP's.

  1. Object
  2. Class
  3. Inheritance
  4. Polymorphism
  5. Abstraction
  6. Encapsulation

3) Robust

Java makes an effort to eliminate error prone codes by emphasizing mainly on compile time error checking and runtime checking. But the main areas which Java improved were Memory Management and mishandled Exceptions by introducing automatic Garbage Collector and Exception Handling.


4) Platform Independent

Unlike other programming languages such as C, C++ etc which are compiled into platform specific machines. Java is guaranteed to be write-once, run-anywhere language.

On compilation Java program is compiled into bytecode. This bytecode is platform independent and can be run on any machine, plus this bytecode format also provide security. Any machine with Java Runtime Environment can run Java Programs.

Java is platform Independent Language


5) Secure

When it comes to security, Java is always the first choice. With java secure features it enable us to develop virus free, temper free system. Java program always runs in Java runtime environment with almost null interaction with system OS, hence it is more secure.


6) Multi Threading

Java multithreading feature makes it possible to write program that can do many tasks simultaneously. Benefit of multithreading is that it utilizes same memory and other resources to execute multiple threads at the same time, like While typing, grammatical errors are checked along.


7) Architectural Neutral

Compiler generates bytecodes, which have nothing to do with a particular computer architecture, hence a Java program is easy to intrepret on any machine.


8) Portable

Java Byte code can be carried to any platform. No implementation dependent features. Everything related to storage is predefined, example: size of primitive data types


9) High Performance

Java is an interpreted language, so it will never be as fast as a compiled language like C or C++. But, Java enables high performance with the use of just-in-time compiler.


10) Distributed

Java is also a distributed language. Programs can be designed to run on computer networks. Java has a special class library for communicating using TCP/IP protocols. Creating network connections is very much easy in Java as compared to C/C++.



New Features of JAVA 8

Below mentioned are some of the core upgrades done as a part of Java 8 release. Just go through them quickly, we will explore them in details later.

  • Enhanced Productivity by providing Optional Classes feature, Lamda Expressions, Streams etc.
  • Ease of Use
  • Improved Polyglot programming. A Polyglot is a program or script, written in a form which is valid in multiple programming languages and it performs the same operations in multiple programming languages. So Java now supports such type of programming technique.
  • Improved Security and performance.

Java Editions

Java Editions or we can say the platform is a collection of programs which helps to develop and run the programs that are written in Java Programming language. Java Editions includes execution engine, compiler and set of libraries. As Java is Platform independent language so it is not specific to any processor or operating system.


1. Java Standard Edition

Java Standard edition is a computing platform which is used for development and deployment of portable code that is used in desktop and server environments. Java Standard Edition is also known as Java 2 Platform, Standard Edition (J2SE).

Java Standard Edition has a wide range of APIs such as Java Class Library etc. the best implementation of Java SE is Oracle Corporation’s Java Development Kit (JDK).


2. Java Micro Edition

Java Micro Edition is a computing platform which is used for the development and deployment of portable codes for the embedded and mobile devices. Java Micro Edition is also known as Java 2 Platform Micro Edition (J2ME). The Java Micro Edition was designed by Sun Microsystems and then later on Oracle corporation acquired it in 2010.

Example: micro-controllers, sensors, gateways, mobile phones, printers etc.


3. Java Enterprise Edition

Java Enterprise Edition is a set of specifications and extending Java SE 8 with features such as distributed computing and web services. The applications of Java Enterprise Edition run on reference runtimes. This reference runtime handle transactions, security, scalability, concurrency and the management of components to be deployed. Java Enterprise Edition is also known as Java 2 Platform Enterprise Edition (J2EE), and currently, it has been rebranded as Jakarta EE.

Example: e-commerce, accounting, banking information systems.


4. JavaFX

JavaFX is used for creating desktop applications and also rich internet applications(RIAs) which can be run on a wide variety of devices. JavaFX has almost replaced Swing as the standard GUI library for Java Standard Edition. JavaFX support for desktop computers and web browsers.


Object-Oriented Programming (OOPs) Concept


1. Class

In Java, a Class is a collection of objects. It is a logical entity. Class is also known as blueprint for which an individual object is created. Class does not occupy any space. Following are the components which a class includes:

i. Modifiers

Modifiers are used to define the scope of the class. A class can be public, private or protected.

ii. Class name

The name of the class should begin with a letter. The name of the class and the program is always the same.

iii. Superclass(if any)

Superclass is the Parent class. If any child class inherits the superclass then extends keyword is used.

iv. Body

The body of the class is surrounded by the braces {}.


2. Object

In Java, An Object is an entity which has state and behaviour. It is an instance of a class. It is a physical entity. An object contains an address which takes memory space. Objects do not contain details of data or code. Following are the things which an object contains:

i. State

It is used to represent the attributes of the object

ii. Behaviour

It is used to represent the methods of the object.

iii. Identity

It is the unique name of an object.


3. Polymorphism

If a task can be performed in many different ways then it is known as polymorphism. To achieve polymorphism in java we use method overloading(Static polymorphism) and method overriding(Dynamic polymorphism).


4. Abstraction

Abstraction means to hide internal details and showing only important functionalities. To achieve abstraction, abstract class and interface are used. And 100% abstraction is achieved from the interface.


5. Inheritance

In the concept of inheritance, one object acquires all the properties and behaviours of another object. Using this concept code can be reused. Inheritance is used to provide runtime polymorphism. Following are the important terminologies used:

i. Super Class

A superclass is the parent class or base class whose features can be inherited.

ii. Sub Class

A subclass is an intermediate class also known as a derived class, extended class or child class. It can inherit the superclass using the extend keyword.


6. Encapsulation

Encapsulation means wrapping up code into a single unit. The best example of encapsulation is the Java Class and also the Java bean. Java bean is totally encapsulated class. Encapsulation is also known as data hiding because here the data is hidden in a class.


Naming convention

In Java, the naming convention is not the rule but it is suggested to by the java communities such as Netscape and Sun Microsystems to follow. Following the Naming convention does not generate confusion or erroneous code. All the classes, interfaces, packages, methods and fields of Java programming language have been given specific naming convention. Java uses Camel Case notation for naming methods, variables etc. and TitleCase notation for classes and interfaces.

1. Class

The name of the class should start using uppercase letter and it should be a noun for example colour, Button, System, Thread, etc.

Example:

	
Public class Student
{
-------code-------
}
	

2. Interface

The name of an Interface should start with an uppercase letter and it should be an adjective, for example, ActionListener, Runnable etc.

Example:

	
interface Student  
{  
	------code----- 
}  
	

3. Method

The name of a Method should start with a lowercase letter and it should be a verb, for example, print(), println(). The name of a method can have lowercase as well as an upper case but the name should always start with lowercase and followed by uppercase for example, actionPerformed().

Example:

	
class Student  
{  
-----method----  
void draw()  
{  
------code------  
}  
}  
	

4. Variable

The name of a Variable start with a lowercase letter for example id, name, roll etc. it should not start with special characters like &, $, _ etc. The name of a variable can have lowercase as well as an upper case but the name should always start with lowercase and followed by uppercase, for example, firstName, lastName.

Example:

	
class Student  
{  
int name, s_Id;  
}  
	

5. Package

The name of a Packagestart with a lowercase letter, for example, studytonight, java etc. the name of a package can also contain multiple words but it should be separated by dots (.) for example java.util.

Example:

	
package com.studytonight; //package  
class Student  
{  
----code----
}  
	

6. Constant

The name of a Constantstart with anuppercase letter, for example, RED, GREEN. the name of a Constant can also contain multiple words but it should be separated by an underscore(_) for example MIN_PRIORITY.

Example:

	
class Student  
{  
//constant  
 		static final int MAX_AGE = 21;  
----code----
}  
	

C++ vs Java

Sno. C++ Java
1. It is Platform dependent. It is Platform Independent.
2. It is used for system Programming. It is used for Application Programming.
3. It supports the goto statement. It does not support the goto statement.
4. It supports multiple inheritance. It does not support multiple inheritance but it can be achieved by interfaces.
5. It supports operator overloading. It does not support operator overloading.
6. It supports pointer. It does not support pointer.
7. It uses a compiler. It uses compiler and interpreter.
8. It supports call by value and call by reference. It supports only call by value.
9. Memory management is done using a pointer. Memory management is done by the system.
10. Runtime error detection mechanism is the responsibility of the programmer. Runtime error detection mechanism is the responsibility of the system.
11. Libraries have low-level functions Libraries have high-level functions.
12. It Allows procedural programming as well as object-oriented programming. It allows only the object-oriented programming model.
13. It hasa scope resolution operator (: :) It does not have a scope resolution operator (: :)
14. It supports Points, structure, and union. It supports Threads and interfaces.
15. It has new and delete keyword for object management It has automatic garbage collection for object management.
16. It has destructors. It does not have destructors.
17. It supports Native unsigned arithmetic. It does not support Native unsigned arithmetic.