I have a base abstract logger class, that has an instance variable that I want to be set by the derived class automatically when the code is create. So here is ...
Originally posted by Layne Lund: If you use the code above, you will see that Calendar.getInstance() does not create an instance of Calendar. As you said, this is not allowed. Instead, it instantiates some subclass and returns a Calendar reference to the subclass object. Layne [ March 10, 2005: Message edited by: Layne Lund ]
Keith had a finger-check where he meant to type "incomplete" and got "complete". The whole point of Abstract classes is that you cannot make an instance. Why did the language designers think this was necessary? As Keith said it lets a class designer specify part of a class but leave other necessary parts for later. Many times an abstract class does ...
Hi... I'm not sure, if really calling the getInstance() static method of the Calendar class, you really make an instance of GregorianCalendar. However abstract class can never be directly instantiated, there is something called "annonymous inner type", which allows you to create a no-name subclass of the abstract class and an instance of this: Calendar cal = new Calendar() { @Override ...
Kind Friends & Java-fans, I'm quite a Java-newbie, but I know for sure that an abstract class can NOT be instanced. So -for example- referring to Java API online guide, how can getOutputStream() method of Socket Class return a "real" OutputStream object belonging to OutputStream ABSTRACT Class? I guess it truly returns a concrete subclass of OutputStream, then -maybe- "casted to ...
Roxxor wrote: Thanks alot for your pedagogic answers! I'm not sure if you're being sarcastic or not. If not, you're quite welcome. If you are being sarcastic, you're still welcome, but allow me to explain why I answered that way: It's to give you as clear and precise an understanding of the terminology and mechanics as possible. To be able to ...
You can instantiate abstract class the following two ways: 1. you can create a parameterise constructor in abstact calss and instantiate it's sub class with the help of super(this); 2. you can also instantiate with the help of ananomous class concept. For example class A is abstract class. B its sub class lets assume class A having one abstract method and ...
Factory method is much easier to understand, the code just won't be as flexible as I expected, the factory maethods seem to decide what implementation class to use according to a parameter given, like 1 for new instance of Concrete1, 2 for new instance of Concrete2, etc. Anyway, it's not a big issue.