Java OCA Chapter 5

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

abstract class

A class that is marked with the abstract keyword and cannot be instantiated.

default method

A method defined in an interface with the default keyword in which a method body is permitted.

abstract method

A method that is marked with the abstract keyword defined in an abstract class or interface, for which no implementation is provided in the class or interface in which it is declared. Any concrete subclass inheriting the abstract method must provide an implementation.

virtual method

A method whose precise implementation is not determined until runtime. All nonfinal, nonprivate methods are virtual methods in Java since they may be overridden at runtime.

What is method overriding?

A subclass method has the same method signature as the superclass method.

Which reference type can contain implementation, but does not require it?

Abstract class

Which two reference types cannot be instantiated?

Abstract classes and interfaces

Which two members are valid in interfaces?

Abstract declarations and constants

What is accomplished by reference type casting?

Access to subtype members that are not available through a reference type.

How many classes can a subclass extend directly?

1

Reusing code to extend functionality in a program is a concept related to which feature in Java?

Inheritance

Which feature of Java allows you to reuse code in existing classes by extending them to your own sub classes?

Inheritance

Which reference type cannot contain implementation?

Interface

interface

An abstract data type that defines a list of abstract public methods that any class implementing the interface must provide. An interface can also include a list of constant variables and default methods.

How many classes can be derived from a parent class?

An infinite number

How many interfaces can a class implement?

An infinite number

Which declaration for ConcreteClass indicates it implements the interface InterfaceA?

ConcreteClass implements InterfaceA

When implementing a method declared in an interface or abstract class, which three techniques are available for specified exceptions?

Do not throw an exception, throw the same class of the specified exception or throw a subclass of the specified exception.

Which keyword do you use to create a sub-class?

Extends

Which keyword is required when declaring a concrete class of an abstract class?

Extends

Which keyword is used to declare a subclass of an existing class?

Extends

How many sub-classes can you inherit from a class marked as final?

None

Which class is the implicit superclass of all classes?

Object

Which two modifiers are implicit for methods declared in an interface?

Public and abstract

Which three modifiers are implicit for fields declared in an interface?

Public, static, and final

Given SuperClass obj = new SubClass(), what is the reference type of obj?

SubClass

Which declaration for SubClass indicates its superclass is SuperClass?

SubClass extends SuperClass

Given SuperClass obj = new SubClass(), what is the reference type of obj?

SuperClass

Which is the parent class for All classes in Java?

The Object class

What is method polymorphism?

The actual method that is executed depends on the type of an object, not the reference type of its variable.

When overriding a method that returns a value, what must be true about the data type?

The data type of the overridden method must be compatible with that of the superclass method.

concrete class

The first non-abstract subclass that extends an abstract class. It is required to implement all inherited abstract methods, which have not been implemented in a parent class.

inheritance

The process by which the new child subclass automatically includes any public or protected primitives, objects, or methods defined in the parent class.

polymorphism

The property of a class in Java used to take on many different forms.

polymorphic parameters

The property of method parameters in Java used to accept sub-classes and subtypes of the method parameter type automatically.

In a variable, what corresponds to the type in the variable declaration?

The reference type

multiple inheritance

The rule a class may inherit from multiple direct parent classes. This feature is not supported in Java.

single inheritance

The rule that a class may inherit from only on direct parent class. Java supports single inheritance although the parent class may, in turn, inherit from another class. Java also supports implementing any number of interfaces.

What restriction applies to the target type when performing reference type casting?

The target type must the object type or a valid supertype.

In an object variable, what does the reference type determine?

The visibility of subtype members

hidden method

When a child class defines a static method with the same name and signature as a static method defined in the parent class.

covariant return type

When a method in a child class overrides a method in a parent class, the return type is permitted to be a subclass of the return type of the method defined in the parent class.

child class

When referring to two classes that share inheritance, the class that extends from another class.

parent class

When referring to two classes that share inheritance, the class that is extended by another class.

In polymorphism, what does the object type determine?

Which implementation is executed for overridden methods

Which keyword is used to specify that a class cannot be extended, a field is a constant value, or a method cannot be overridden?

final

Which keyword is used to declare a class that provides interface implementation?

implements

Which operator determines whether an object matches a reference type or one of its supertypes?

instanceof

Which keyword is used to access superclass members within a subclass?

super


Set pelajaran terkait

Maintenance Exam: Practice Exam #2 (Dewalt - 2017)

View Set

1.3 Order of Operations Vocabulary & Examples

View Set

SP6 Llama: Palabras y Definiciones

View Set

Statistics Math 125 - Module 1 Quiz 1

View Set