Generic Methods in Java 5.0

java-thumbnail

In java 1.5 we have a feature called generic methods, with this we can write a method, which can be generic, means it can be called by any parameter and behavior of the method will be according to the parameter passed. Assume that we need to write a method which takes an array and converts […]

Handle exceptions in overriding methods

java-thumbnail

The question why makes any topic makes more clearer and interesting than just to know about what the concept is. The rule about exceptions when we use them in overriding is: If super class method is throwing any exception(checked) and if we are overriding that method in sub class. also read: New Features in Java […]

Hiding and Overriding Methods In Java

java-thumbnail

Now in section Inheritance mainly in Hiding And Overriding Methods can we predict the output of the following program? also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java File IO Tutorials It Prints: Here the overriding methods getX and getY in class RealPoint have the same return types as the methods of class […]

Static keyword in Java

java-thumbnail

What is Static? static variables and static methods might better have been called perClass variables and methods. They inherited this misleading terminology from C++. They are the opposite of instance variables and methods that work on a particular object. also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java File IO Tutorials Can we […]

Decorator Design Pattern in Java

java-thumbnail

Intent of Decorator Design Pattern: Attach additional responsibilities to an object dynamically.Decorators provide a flexible alternative to subclassing for extending functionality.[GoF,p175] Client specified embellishment of a core object by recursively wrapping it. Wrapping a gift,putting it in a box and wrapping the box. also read: Design Pattern Interview Questions Factory Design Pattern State design pattern […]

Iterator Pattern

java-thumbnail

What is Iterator Pattern? Provide a way to access the elements of the aggregate object sequentially without exposing its underlying representation. Aggregate object is an object that contains other objects for the purpose of grouping those objects as a unit.It is also called a container or a collection.Examples are linkedList,Hashtable,ArrayList etc. also read: Design Pattern […]

Abstract Factory Pattern

java-thumbnail

What is Abstract Factory Pattern? Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Wikipedia says: A software design pattern, the Abstract Factory Pattern provides a way to encapsulate a group of individual factories that have a common theme. also read: Design Pattern Interview Questions Factory Design Pattern […]

Template Design Pattern

java-thumbnail

What is Template Design Pattern? An abstract class defines various methods and has one non-overridden method which calls the various methods. also read: Design Pattern Interview Questions Factory Design Pattern State design pattern Wikipedia Says: A template method defines the program skeleton of an aligorithm.The aligorithm itself is made abstract,and the subclasses override the abstract […]

Closures in Java 7.0

java-thumbnail

What is a closure? Wikipedia says: A closure is a function that is evaluated in an environment containing one or more bound variables.(Free variables which are to be passed to the function).In some languages closures may occur when a function is defined within another function and the inner function refers to the local variables of […]

Inner Classes in Java

java-thumbnail

As we all know what an inner class is so lets try to know few more rules about Inner Classes. Inner classes cannot have static members. only static final variables. also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java File IO Tutorials Interfaces are never inner. Static classes are not inner classes. Inner […]