|
Let's say I have an abstract class called ViewController, and another abstract class called FormViewController. When someone wants to create a form, he must subclass FormViewController and implement its abstract classes.
ViewController defines an abstract...
Started by openfrog on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Yes, actually thats a widelly used design pattern on many OOP languages. .
The best way to prove it is to try it and see .
It's okay with any object-oriented language.
|
|
Is it necessary for an abstract class to have at least one abstract method?
Started by java_geek on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
In JDK 1.0 it was indeed necessary to have at least one abstract method in an abstract class a class (with....
It may not make any.
No - you can declare a class abstract without having any abstract methods.
|
|
Hi I have a doubt regarding HttpServlet class is an abstract class even though there is not any abstract method in the class , all methods are concrete. Can class be abstract even if does not have any abstract methods? If yes Whats the use?
Thanks
Answer Snippets (Read the full thread at stackoverflow):
If the class is abstract, you can't create an instance of that class sense to have an unspecialised instance of that class, so it's abstract so the compiler drops a hint to anyone who....
It's a matter of intent.
|
Ask your Facebook Friends
|
Please help :/
In Java you can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces?
Cheers!
Started by Registered User on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Not always:
a class can extend only one class a class can implement more than one implementation....
However, it hardly ever a good abstract class.
In some cases you can use an abstract class instead of interface.
|
|
In OOP, I see a lot of classes which derive from parent classes, but the parent classes are not marked as abstract. When the class IS marked as abstract, what advantage does this provide?
Thanks
Started by dotnetdev on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Essentially, the abstract definition on a class indicates that it was not intended to be instantiated it?
The difference is really....
An abstract class cannot be instantiated by itself; it must be derived from to be instantiated.
|
|
I am creating an abstract class. I want each of my derived classes to be forced to implement a specific signature of constructor. As such, I did what I would have done has I wanted to force them to implement a method, I made an abstract one.
public abstract...
Started by Anthony D on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
To an object of a derived class, define an abstract method which needs to be implemented by derived classes a factory method in an interface - but you'll need a separate factory class as your abstract base class....
|
|
If you have several classes where you want them to inherit from a base class for common functionality, should you implement the base class using a class or an abstract class?
Started by Joan Venge on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
The depends on whether you want the base class to be implemented....
That depends, if you never want to be able to instantiate the base class then make it abstract by itself, the then you should define it as an abstract class.
|
|
An abstract base class (interface class) usually has all its member functions abstract. However, I have several cases where member functions consisting of calls to the abstract methods of the interface are used. I can implement them in a derived-but-still...
Started by andreas buykx on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
It okay for an abstract base class to have non-abstract methods (as per your question title) but I ....
If you really want an interface, it is probably best to use your second implementation .
In an abstract base class.
|
|
So i need to get the Class of an object at runtime, and sorry guys Javas not my home ;0)
For an none abstract class i could do something like:
public class MyNoneAbstract{ public static Class MYNONEABSTRACT_CLASS = new MyNoneAbstract().getClass();
But...
Started by Philip.ie on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
That means an Object at runtime cannot have its class be abstractYou....
The code you want in the abstract case is:
public abstract class MyAbstract{ public static Class, an abstract class cannot be instantciated.
|
|
Hi, I'm new to Java.
Why are abstract or interface classes created, or when should we use abstract or interface classes?
Started by JavaResp on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Any class extending the abstract class will have to implement only its abstract methods and members, and will have some default implementation....
If you also want to have a default implementation, use abstract class.
|