There can be a abstract class without abstract methods, but
what is the need to declare a class abstract if it doesn't
contain abstract methods?
Answer Posted / gkp
Abstract class and Interface are the design time decision. As we expect to extend our implementation in future so we need to give space to incorporate new implementation. As we know if some implementation of a method will be common in many classes then that method should be moved to abstract class so the repetition of same code can be avoided. Even though we don't have any abstract method in our abstract class, we can go for a abstract class. Generally in design of java classes, it is designed like, first an interface then an abstract class and then concrete class implementation starts.
| Is This Answer Correct ? | 5 Yes | 1 No |
Post New Answer View All Answers
What are the advantages of functions?
Write a java program to count the number of words present in a string?
What is the function of static in java?
What is the purpose of javac exe?
When should I use a singleton?
how can you catch multiple exceptions in java?
What best practices should you follow while writing multithreaded code in java?
What is a method in java?
Tell me about your ability to work under pressure
What is the difference between stringbuffer and stringbuilder?
What is default switch case? Give example.
How to stop a thread in java? Explain about sleep () method in a thread?
Can an interface have a class?
What should I import for arraylist in java?
What is super constructor?