Beruflich Dokumente
Kultur Dokumente
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
MTODOS
Los mtodos son funciones que determinan el
comportamiento de los objetos.
Un objeto se comporta de una u otra forma
dependiendo de los mtodos de la clase a la que
pertenece.
Todos los objetos de una misma clase tienen los mismos
mtodos y el mismo comportamiento.
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
SOBRECARGA DE MTODOS
La sobrecarga de mtodos es til para que el mismo
mtodo opere con parmetros de distinto tipo o que un
mismo mtodo reciba una lista de parmetros diferente.
Esto quiere decir que puede haber dos mtodos con el
mismo nombre que realicen dos funciones distintas.
La diferencia entre los mtodos sobrecargados est en su
declaracin.
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
CONSTRUCTORES
Para crear un objeto se utiliza el operador new. Si no se ha
definido un mtodo constructor para la clase, entonces el objeto
se instancia indicando el nombre de la clase y a continuacin un
parntesis abierto y otro cerrado.
Si ya se ha definido un mtodo constructor, entonces no es
posible instanciar un objeto utilizando el constructor por
defecto. Cuando se invoca al constructor por defecto se asigna
un espacio de memoria para el nuevo objeto y sus atributos se
inicializan a los valores por defecto correspondientes a su tipo.
Los nmeros enteros se inicializan a cero, los nmeros reales a
0.0, los valores lgicos a false, los caracteres se inicializan a
\u0000 y las referencias a null.
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
En una clase se pueden definir uno o ms mtodos constructores para inicializar los
atributos de un objeto con valores distintos de los valores por defecto de Java. Para
instanciar un objeto es necesario indicar los valores iniciales de sus atributos cuando se
ejecuta el mtodo constructor. En la clase Vehiculo se ha definido un mtodo
constructor que inicializa los atributos matricula, marca, modelo, color y tarifa.
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)