logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

  • Question
  • When should I use abstract classes and when should I use interfaces?


  • Correct Answer
  • Use Interfaces when? - You see that something in your design will change frequently - If various implementations only share method signatures then it is better to use Interfaces - You need some classes to use some methods which you don't want to be included in the class, then you go for the interface, which makes it easy to just implement and make use of the methods defined in the interface Use Abstract Class when? - If various implementations are of the same kind and use common behavior or status then abstract class is better to use - When you want to provide a generalized form of abstraction and leave the implementation task with the inheriting subclass - Abstract classes are an excellent way to create planned inheritance hierarchies They're also a good choice for nonleaf classes in class hierarchies 


  • Technology problems


    Search Results


    • 1. Explain Overriding Polymorphism.?
    • Discuss
    • 2. When do you use :: Operator in C++?
    • Discuss
    • 3. What is polymorphism?
    • Discuss
    • 4. What is JAR file?
    • Discuss
    • 5. In RDBMS, what is the efficient data structure used in the internal storage representation?

    • Options
    • A. Stack
    • B. Queue
    • C. B+ tree structure
    • D. AVL tree Structure
    • Discuss
    • 6. How do you traverse through a collection using its Iterator?
    • Discuss
    • 7. How do you decide when to use ArrayList and When to use LinkedList?
    • Discuss
    • 8. What is the Set interface ?
    • Discuss
    • 9. What is the SimpleTimeZone class?
    • Discuss
    • 10. What are Native methods in Java?
    • Discuss


    Comments

    There are no comments.

Enter a new Comment