1) Base of hexadecimal number system? Answer : 16 2) Universal gate in digital logic? Answer : NAND 3) Memory type that is non-volatile? Answer : ROM 4) Basic building block of digital circuits? Answer : Gate 5) Device used for data storage in sequential circuits? Answer : Flip-flop 6) Architecture with shared memory for instructions and data? Answer : von Neumann 7) The smallest unit of data in computing? Answer : Bit 8) Unit that performs arithmetic operations in a CPU? Answer : ALU 9) Memory faster than main memory but smaller in size? Answer : Cache 10) System cycle that includes fetch, decode, and execute? Answer : Instruction 11) Type of circuit where output depends on present input only? Answer : Combinational 12) The binary equivalent of decimal 10? Answer : 1010 13) Memory used for high-speed temporary storage in a CPU? Answer : Register 14) Method of representing negative numbers in binary? Answer : Two's complement 15) Gate that inverts its input signal? Answer : NOT 16)...
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.