Unit 2 (prog 7) : Test clone() method

By | June 19, 2013

In this Example, you can find the Cloneable interface and Clone method usage in java. and also various ways to create object in java. /*  * Object cloning is a way to create exact copy of an object.  * To use clone() method of java.lang.Cloneable interface, class must implement it else CloneNotSupportException will be thrown.… Read More »

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 6) : Test Static Keyword

By | June 9, 2013

This article covers basics of static keyword, static methods and static variables. /*  * STATIC METHODS :  * 1. Static method can not access non-static (Instance) variable or method.  * 2. Static method can not be overridden they are redefined.  */

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 1 ( Prog 2) : Test Access Modifiers

By | June 2, 2013

Use of access modifiers and class properties… /*   * Question : value of rightFirst will be always one third of leftFirst or not ?  * NO because both are public, no need to use setLeft() method for that  * those are directly accessible…:p  * but it is true in case of class ValueSecond  */ class… Read More »

UNIT 1 (Concept 1) : Access Modifiers in java

By | June 2, 2013

Visibility of the properties  of class for different access modifiers  ——————————————————————————————————————– 1) From the same class           Public , Protected, Private and Default 2) From any class in same package           Public, Protected and Default 3) From a subclass in same package          … Read More »

Unit 2 (Prog 3) : Test equals() method.

By | June 2, 2013

Testing of equals() method and overriding equals() method of Object class. // Overriding equals() method will make an object identical // to use a object as a key, one has to override equals() method of Object class   public class EqualsTest {           public static void main(String[] args) {    … 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 »