Question 1: Please answer the following sub questions
1.1) What happens to connection information if you change mysql port number?
1.2) Why is it important to create an interface?
1.3) Why would you want to use java interfaces?
1.4) Why override methods of interface and not just create them?
1.1) If the MySQL port number changes, the existing connection will still continue to exist, but any new connection will fail to establish, and hence will throw exception.
1.2) An interface allows a developer to separate the functionality with its implementation. The user of an application need not worry about how the functionality is implemented and can straightaway use it. It creates fewer problems, increases user involvement, perfects functionality.
1.3) Interfaces are more flexible, because a class can implement multiple interfaces. Since Java does not have multiple inheritance, using abstract classes prevents your users from using any other class hierarchy. In general, prefer interfaces when there are no default implementations or state.
1.4)
An interface method does not have any implementation and is black. Whichever class is implementing the interface need to override the methods with their own implementations.
Get Answers For Free
Most questions answered within 1 hours.