What is difference between abstract class & final class
Answer Posted / farhad
A final class CANNOT be extended or subclassed however it can be instantiated:
final class A{
}
class B{
A a = new A(); //<<< instantiating final class A
We cannot say:
class B extends A //!!! that's a NO NO.
On the other hand abstract class can be subclassed but CANNOT be instantiated.
abstract class A{
}
class B extends A{
}
| Is This Answer Correct ? | 9 Yes | 6 No |
Post New Answer View All Answers
Enlist diffrent types of inheritance supported by java?
What is mnemonic in assembly language?
What is not thread safe?
What is the use of put method?
Explain why wait(), notify() and notifyall() methods are in object class rather than in thread class?
Write a program to find the whether a number is an Armstrong number or not?
Write a method that will remove given character from the string?
do I need to use synchronized on setvalue(int)? : Java thread
Why do we need wrapper classes?
What is difference between class and object in java?
What is the class in java?
Can a class with private constructor be extended?
I want to control database connections in my program and want that only one thread should be able to make database connection at a time. How can I implement this logic?
Can you give few examples of final classes defined in java api?
What is the this keyword?