P. 1
Cristian Frasinaru-Curs Practic de Java

Cristian Frasinaru-Curs Practic de Java

|Views: 2|Likes:
Published by Andreea gin
curs
curs

More info:

Published by: Andreea gin on May 23, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

07/17/2013

pdf

text

original

Spre deosebire de alte limbaje de programare orientate-obiect, Java permite

doar mo¸stenirea simpl˘a, ceea ce ˆıneamn˘a c˘a o clas˘a poate avea un singur

p˘arinte (superclas˘a). Evident, o clas˘a poate avea oricˆati mo¸stenitori (sub-

clase), de unde rezult˘a c˘a mult¸imea tuturor claselor definite ˆın Java poate fi

vazut˘a ca un arbore, r˘ad˘acina acestuia fiind clasa Object. A¸sadar, Object

este singura clas˘a care nu are p˘arinte, fiind foarte important˘a ˆın modul de

lucru cu obiecte si structuri de date ˆın Java.

2.2. CREAREA CLASELOR

41

Extinderea unei clase se realizeaz˘a folosind cuvˆantul cheie extends:

class B extends A {...}

// A este superclasa clasei B

// B este o subclasa a clasei A

O subclas˘a mo¸stene¸ste de la p˘arintele s˘au toate variabilele ¸si metodele

care nu sunt private.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->