Scrigroup - Documente si articole

Username / Parola inexistente      

Home Documente Upload Resurse Alte limbi doc  

AccessAdobe photoshopAlgoritmiAutocadBaze de dateCC sharp
CalculatoareCorel drawDot netExcelFox proFrontpageHardware
HtmlInternetJavaLinuxMatlabMs dosPascal
PhpPower pointRetele calculatoareSqlTutorialsWebdesignWindows

AspAutocadCDot netExcelFox proHtmlJava
LinuxMathcadPhotoshopPhpSqlVisual studioWindowsXml

Combining composition and inheritance


+ Font mai mare | - Font mai mic


Trimite pe Messenger
protected: “sort of friendly”
StreamTokenizer: StringTokenizer
Array initialization
Web Applications
Creating new data types: class
Initializing the base class
Logical operators
Sharing limited resources: Improperly accessing resources
Ternary if-else operator

Combining composition
and inheritance

It is very common to use composition and inheritance together. The following example shows the creation of a more complex class, using both inheritance and composition, along with the necessary constructor initialization:


// Combining composition & inheritance

class Plate

class DinnerPlate extends Plate

class Utensil

class Spoon extends Utensil

class Fork extends Utensil

class Knife extends Utensil

// A cultural way of doing something:

class Custom

public class PlaceSetting extends Custom

  public static void main(String[] args)

While the compiler forces you to initialize the base classes, and requires that you do it right at the beginning of the constructor, it doesn’t watch over you to make sure that you initialize the member objects, so you must remember to pay attention to that.

Politica de confidentialitate



Vizualizari: 346
Importanta: rank

Comenteaza documentul:

Te rugam sa te autentifici sau sa iti faci cont pentru a putea comenta

Creaza cont nou

Termeni si conditii de utilizare | Contact
© SCRIGROUP 2022 . All rights reserved

Distribuie URL

Adauga cod HTML in site