Created
August 22, 2012 01:03
-
-
Save mailtoharshit/3421076 to your computer and use it in GitHub Desktop.
Subclass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SubClass with Method Override | |
public virtual class myParentClass { | |
public virtual void dosomething() | |
{ | |
System.Debug('Something'); | |
} | |
public class myclass extends myParentClass | |
{ | |
public override void dosomething() | |
{ | |
super.dosomething(); | |
System.Debug('something else'); | |
} | |
new myclass().dosomething(); | |
} | |
//Abstract Method and Override | |
public abstract class myBaseClass{ | |
public abstract void dosomething (); | |
} | |
public class MyClass extends myBaseClass{ | |
public override void dosomething() | |
{ | |
System.Debug('something'); | |
} | |
} | |
new MyClass.dosomething(); | |
// Using instanceof Keyword | |
List <ClassA> newList = new List<ClasA>(); | |
newList.add(new ClassA()); | |
newList.add(new ClassB()); | |
System.Debug(newList.get(2) instancof ClassB); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment