Contents
Java is a high level programming language, invented by James Gosling in 1991 and is well known to most part in the industry since 1994, when it is publicly available. It has a bigger library that keeps increasing regularly. Java is mostly concentrated over what to do rather than how to do. I.e. In Java, building blocks are ready-made so that business logics can easily be made making application development much faster. To start with Java we must be aware of the basic concepts of the programming. Java is a pure Object oriented programming language, if we left few things apart like (primitive data types, Operator Overloading, Multiple Inheritance, et). So the first thing to know is about Objects.
What is a Java Object?
Mapping of a real world entity into a software bundle. In the similar manner, States and behaviours of the real world entity is mapped to fields and methods respectively of the software bundle. more details. Field is a specification of states of a real world entity whereas Method specifies behaviours.
What is a Java Class? What types of they are?
Class is a model of an object. A class represents a family of objects and each object becomes an instance of the class if derived from it.
Abstract Class has at least one abstract method. Abstract class can never be instantiated.
Internal Class is any class inside another class. However, every class is an Internal class to itself.
Anonymous Class does not possess any defined name. They are created in the body of a method and named at runtime by the system itself. e.g. look at the following code which describes how an anonymous class get implemented.
Runnable runnable = new Runnable(){ public void run(){ //Your code here } };
Here Runnable is an interface, runnable is referencing an implementation of Runnable interface. Since there is no class name specified for the implementer, We call it an Anonymous class. When this code is compiled, the class created is named as $1.class following the super class name. Usually we use anonymous implementation while creating threads and Comparators.
What is a Java Interface? What are its properties and different types?
Its a bundle of most abstract form of an entity. At the interface level external world knows about the behaviour name of the entity but how will they behave is unknown. Therefore, no definition is possible in an interface and every behaviour must be defined somewhere to realise them and hence each method must be declared as non private in an Interface.
Properties : An Interface can only be declared as public or abstract or both public and abstract and can not be instantiated. It can extend any number of interfaces of any visibility type. A field in an Interface can have either no modifier or a combination of public, final or static modifiers. Similarly a method can have either no modifier or a combination of public or abstract modifiers.
Marker Interface : An Interface with no method declaration and no fields attached. It is used to legalise and indicate a peculiar behaviour of the class once a Marker Interface is implemented. E.g. java.lang.Clonable, java.io.Serializable, java.util.RandomAccess, javax.servlet.SingleThreadModel, java.util.EventListener, et.
What is Polymorphism? How Polymorphism affects Java?
A strategy to have an appearance in many forms. Dynamic Binding or Late binding happens at run time and comes in picture where a reference of superclass to its subclass is needed. Instead of superclass, an interface can also be used. In Method Overloading, multiple methods can have same name but they must have different parameters. Method Overriding provides a flexibility to redefine the inherited method in own manner.
What is an Inheritance? Detail its properties in terms of Java language? Explain Multiple Inheritance in Java?
Inheritance is a feature in which a subclass gets all the public, protected and friend properties of its parent. private members can not be inherited. If subclass wants to write its own method then it will become Polymorphism's feature known as Method Overriding.
Multiple Inheritance is supported in Java via a different path(unlike C++) than directly through classes. You need to extend multiple interfaces from your master interface or you need to implement multiple interfaces from your class.
What is Encapsulation?
Best way to understand Encapsulation is to look an Interface. Keeping states and behaviours of an object into a single box, which could be an Interface or a Class is called Encapsulation.
Multithreading
Java has made multi threading lot easier to program. Its vast API for concurrent processing has made coding very easy. I use following links to have good grasp over threading.
- Article : How to write multithreaded Java applications
- Article : Concurrent Java collections classes
- Algirithm, Parallel programming : Map reduce Algorithm at Google with example
- Algirithm : Map reduce Algorithm for converting sequential programs to parallel program
- Tutorial : Fundamentals of multithreading in Java
- Tutorial : Concurrency Tutorial at Java.sun.com
- Tutorial : Programming Java threads in the real world
Java Other Links
- Java practice- API Documentation Java 7, Java 6, Java 5, Java 4, Java 3
- Java Design Patterns
- Tuning Garbage Collection with the 5.0 JavaTM Virtual Machine