Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
The 'is a' relationship is used with inheritance and 'has a' relationship is used with composition. Both composition and inheritance allow you to perform sub-objects inside your new class. Two of the main techniques for code reuse are object composition and class inheritance.
Inheritance is single-directional. For example man is a human. But human is not a man. Inheritance needs extends key word. Composition: is used when Man has an eye. It is incorrect to say man is an eye. Composition simply defines using instance variables that refer to other objects. The class man will have an instance variable, which refers to an eye object.
Which one to favor, inheritance or composition? The guide is that inheritance could be only used when subclass 'is a' superclass.
1. Don't use inheritance just to get programming code reuse. If there is no 'is a' relationship then require composition for code reuse. Overuse of implementation inheritance will divide all the subclasses, if the superclass is changed.
2. Do not add inheritance just to get polymorphism. If there is no 'is a' relationship and all you need is polymorphism then use interface inheritance with composition, which provides you code reuse.
Java says write once, run anywhere . In which ways this isn't quite applicable ?
Mike sells on the average 15 newspapers per week (Monday – Friday). Find the probability that 2.1 In a given week he will sell all the newspapers [7] 2.2 In a given day he will se
What are the advantages of multimedia presentations? Write any five. Multimedia presentation is a excellent tool for effective communication: Advantages: 1. Easy to make l
Who Can an Applet Talk To? By default an applet can just open network connections to the system from that the applet was downloaded. This system is known as the codebase. An ap
Employee get data from console
Assume all the obstacles are of height 4 units and the blocks are of heights 1 (bottom), 2 (top), 1 and 2 (top) units respectively. Complete the control() method of the RobotContr
The non-final functions are clone (), finalize (), toString (), equals () , hashCode () and. The other methods like wait (), getClass (), notifyAll (), notify () etc are final
What are the List interface and its main implementation? List helps in collections of objects. Lists may include duplicate elements. Main implementations of List interface are
Explain The Methods of java.lang.Object? java.lang.Object gives a number of methods that are general to all objects. toString() is the most general such method. Because the def
Explain Parentheses in Java ? Sometimes the default sequence of evaluation isn't what you want. For example, the formula to change a Fahrenheit temperature to a Celsius tempera
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +91-977-207-8620
Phone: +91-977-207-8620
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd