Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

instance of an abstract class

take Calendar

On the API page it is described as an abstract class, yet you
obtain it with it's static getInstance method.  Please explain.
Everywhere I turn instructors say you can not get an object
of an abstract class.  Does getInstance build something else?,
something which extends Calander?

Thanks
0
hank1
Asked:
hank1
  • 4
1 Solution
 
CEHJCommented:
You don't obtain it. You get a subclass that's assigned to a variable of type abstract
0
 
CEHJCommented:
>>Does getInstance build something else?,
something which extends Calander?

Yes
0
 
CEHJCommented:
Usually GregorianCalendar:

System.out.println(Calendar.getInstance().getClass());
0
 
hank1Author Commented:
So you can call static methods of abstract classes.
THis, and who know why, also works Cal.. c = new Cal...()

I didn't think you could do that either.

Thanks
0
 
CEHJCommented:
:-)

>> So you can call static methods of abstract classes.

yes

>>THis, and who know why, also works Cal.. c = new Cal...()

No it won't compile
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now