Skip to content

Instantly share code, notes, and snippets.

@mailtoharshit
Created August 22, 2012 01:03
Show Gist options
  • Save mailtoharshit/3421076 to your computer and use it in GitHub Desktop.
Save mailtoharshit/3421076 to your computer and use it in GitHub Desktop.
Subclass
// 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