CMSC132 - Final Exam Review(Corrrectly solved)
Subclasses correct answers - inherits all properties, behaviors, and fields of its superclass - inherits private fields and methods in its superclasses, but it cannot directly access them - can have more methods than its superclass - classes can only extend one superclass - subclass is a type of a superclass object - constructor automatically calls its superclass's default constructor (error if it doesn't have one) - can explicitly invoke its superclass constructor using super - execution order: most parent to most sub - can redefine (override) methods in a superclass, but must have the same name and signature - can call an overriden method in a superclass using super( ) - can define a field with the same name as a superclass field Superclasses correct answers - can refer to an object of any of its subclasses object-name instanceof classname correct answers - returns true if object is of the type classname or if is an object of any of its subclasses Class() correct answers - returns a reference to something called a class object (unique object for each class in program), which can be compared using == or equals() to see if object is the same class as another object Dynamic binding correct answers - the type of a object that a superclass reference refers to determines which method gets called (when methods are overridden) - DOES NOT APPLY TO STATIC METHODS Final correct answers - methods cannot be overridden by subclasses - classes cannot be extended (no subclasses) The Object class correct answers - the (direct/indirect) superclass of all other classes in Java - doesn't have fields, but it does have methods (equals( ) and toString( )) Interfaces correct answers - A collection of: ~ Constants ~ Method signatures (or prototypes), but no implementations - a class can only implement one interface at a time - Restriction of interfaces: CAN'T INSTANTIATE AN INTERFACE - Reference of an interface type object - an object of any class that implements the interface
Información del documento
- Subido en
- 28 de mayo de 2024
- Número de páginas
- 8
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas