Category Archives: Inheritance

Polymorphism in Java

By | March 30, 2014

This article contains… What is Polymorphism ? Reference variable types and Object Example of Polymorphism Runtime and Compiletime Polymorphism Example of both SCJP exam objective 5.2

Inheritance, IS-A and Has-A

By | February 28, 2014

Contents : IS-A relationship in OOP (Inheritance) Has-A relationship (Association) Different type of Association : Aggregation and Composition Example of each type SCJP exam objective 5.5

Unit 2 (Prog 6) : Inheritance in JAVA

By | February 10, 2014

Content : What is Inheritance ? Example of Inheritance. Reason to use Inheritance. What you can do in child class ?

Unit 8 (Prog 2) : Test Inner Class 2nd

By | June 13, 2013

In this example you will find Anonymous Inner class concepts, Inner class concepts in java, and also some tricks about Interface. /*  * TestAnonymousInnerClass.java  *  * This Example includes…  *          1. Method inside Interface with body.  *          2. Inner Class inside Interface.  *          3.… Read More »

Unit 8 (Prog 1) : Test Inner Class

By | June 11, 2013

In this example, you will find the concept of Inner class in java, how to declare and access the inner class properties. Access modifiers and their effect on inner class properties. Java doc for Inner class in given Here : Inner class in java

Unit 2 (Prog 5) : Constructors in java

By | June 5, 2013

Constructor Demo code… /*  * 1. Constructor can use any return type.  * 2. Constructor name must match the name of class.  * 3. constructor must not have a return type.  * 4. If you see a method with return type having same name as class than it is just a method.  * 5. if… Read More »

Unit 2 (Prog 4) : Test Overloading and Overriding

By | June 3, 2013

Overloading v/s Overriding methods… class Operator {           public int operation(int x, int y) {                     System.out.println(“First method invoked from parent class.”);                     return x + y;           }… Read More »

Unit 2 (Prog 2) : Accessing Super Class method

By | June 2, 2013

Accessing Super Class method : class ParentShape {           public void displayShape(Object o) {                     System.out.println(“displaying parent shape from ” + o.toString() );           } // more code } class ChildOne extends ParentShape {        … Read More »

Unit 2 (Prog 1) : Test Inheritance of class in JAVA

By | June 1, 2013

Inheritance Test for OCJP preparation… /*  * equals() method is defined under  * java.lang.Object class which is inherited by all class having main method  *  * thus every class is instance of java.lang.Object class  * Whenever you create a class, you automatically inherit all of class Object’s methods.  */ public class ch21TestClassInheritance {    … Read More »