Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 OOP questions
Index -> Programming, Java -> Java Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Marfhew




PostPosted: Mon Feb 25, 2013 8:00 pm   Post subject: RE:OOP questions

Polymorphism is storing a subclass typed variable in a superclass typed variable. That was terrible wording. Look at my example:
code:

public class A{
//Not important
}

public class B extends A{
//Not important
}

So B is a subclass of A
Polymorphism is doing this:
A variableName = new B();
It's convenient when you have multiple subclasses of A and you want to interchange which subclass type the variable holds
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 16 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: