Smart Grids and Energy Storage Systems: Powering the Future of Energy In today’s rapidly evolving energy landscape, the push towards sustainability, efficiency, and reliability is stronger than ever. Traditional power grids, though robust in their time, are no longer sufficient to meet the demands of a modern, digital, and environmentally conscious society. This is where smart grids and energy storage systems (ESS) come into play — revolutionizing how electricity is generated, distributed, and consumed. What is a Smart Grid? A smart grid is an advanced electrical network that uses digital communication, automation, and real-time monitoring to optimize the production, delivery, and consumption of electricity. Unlike conventional grids, which operate in a one-way flow (from generation to end-user), smart grids enable a two-way flow of information and energy. Key Features of Smart Grids: Real-time monitoring of power usage and quality. Automated fault detection and rapid restoration. Int...
Q) What is composition in Java ?
Composition is the design technique to implement has a relationship in classes. We can use object composition for code reuse.
Java composition is achieved by using instance variables that refer to other objects. The benefit of using composition is that we can control the visibility of other objects to client classes and reuse only what we need.
Q) What is the benefits of composition over inheritance ?
Prefer composition over inheritance is a one of the popular object oriented design principles, some of the possible reasons are
1) Inheritance is tightly coupled whereas composition is loosely coupled.
2) Any change in superclass might affect subclass even though we might not be using the superclass methods. For example, if we have a method test() in the subclass and suddenly somebody introduces a method test() in the superclass, we may get compilation errors in the subclass. Composition will never face this issue because we are using only what methods we need.
3) Inheritance expose all the superclass methods and variables to the client and if we have no control in designing superclass, it can lead to security holes. Composition allows us to provide restricted access to the methods and hence more secure.
4) One more benefit of composition over inheritance is testing scope. Unit test is easy in composition because we know what all methods we are using from other class. We can mock it up for testing whereas in inheritance we depend heavily on superclass and don't know what all methods of superclass will be used. So we will have to test all the methods of superclass. This is an extra work and we need to do it unnecessarily because of inheritance.
Q) What does super keyword do ?
super keyword can be used to access super class method when you have overridden the method in the child class.
We can use super keyword to invoke superclass constructor in child class constructor but in that case, it should be the first statement in the constructor method.