Skip to main content

Posts

Featured

It is all about abstraction...

  Q: What is an interface in Java and why would you, as a software developer, use interfaces? A: So far, we have got an idea of what a class is in Java. Let’s say that an interface is like a class; however, it has no attributes but contains abstract methods. If a programmer has created different classes and wanted these classes to have the same methods. It is too time-consuming to write all those methods repeatedly for each class. In this case, interfaces come in handy. One can implement one interface, containing all those methods, in all of those classes and the job is done. Q: What is the difference between an abstract class and an interface? In many aspects, abstract classes and interfaces are similar and both are used to achieve abstraction. However, methods declared in abstract classes are not only abstract methods, but they can also be public, private, and protected (like a doodle() method in the example below). The fields declared with abstract classes are also not on

Latest Posts

Concurrency