100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Notas de lectura

CE203 revision notes from lecture 3 onwards ()

Puntuación
-
Vendido
2
Páginas
17
Subido en
01-08-2017
Escrito en
2016/2017

Complete lecture notes from the CE203 module, application programming from the 3rd lecture onwards, language covered in lectures is Java. Topics range from Inheritance, collections framework, swing, classes, and more

Institución
Grado








Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

Subido en
1 de agosto de 2017
Archivo actualizado en
1 de agosto de 2017
Número de páginas
17
Escrito en
2016/2017
Tipo
Notas de lectura
Profesor(es)
Desconocido
Contiene
3-9

Temas

Vista previa del contenido

CE203 revision Lecture 3 onwards

Inheritance

To invoke the constructor from the superclass within the subclass constructor, you have to use the
‘super’ command which must be the first statement in the constructor

If the statement does not exist then a no-argument error will occur

A superclass may refer to an object of the subclass

To access subclass method for a variable declaration, you must use downcasting, this tells the
compiler that the variable will refer to a subclass object

This can be done like

Int r = ((subclass)subclassObect).method();

The odd parentheses order is necessary since method application has a higher precedence than
downcasting, without them the downcast would be applied to the result of just the method name

If the subclass object variable didn’t refer to the subclass, an exception called ClassCastException will
be thrown.

Subclass objects can be stored in an array of superclass objects

If you wish to find all the subclass objects in an array of both the superclass and sub class, you should
use ‘instanceof’. Example below:



For (int i = 0; I < a.length; i++)

If(a[i] instanceof subclass)

System.out.println(a[i]);



To copy the contents of one array into another, you can use a method which takes both the arrays as
Object[] arguments, throws ArrayStoreException if the destination array is shorter than the source,
and then iterates through the items of the source array and dest[i] = source[i]

The method only works if the element types of both arrays’ arguments are the same, for example
both int.

And if the source array type is a subclass of the destination array type

Abstract classes:

An abstract class is a class that cannot be instantiated, only inherited from.

All inheriting classes can use methods from the abstract class

Abstract classes provide more a framework that allows subclasses to be interchanged with other
inheriting subclasses, similar to headers in C++.

Interfaces:
$4.82
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
jacksmith1

Conoce al vendedor

Seller avatar
jacksmith1 The University of Essex
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
2
Miembro desde
8 año
Número de seguidores
2
Documentos
1
Última venta
2 año hace

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes