Java final 2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Error

Classes that inherit from ______ are for exceptions that are thrown when a critical error occurs, such as an internal error in the JVM or running out of memory

AccessSpecifier abstract ReturnType MethodName(parameterList);

General format of an abstract method header:

functional interface

If a __________'s abstract method has multiple parameters, any lambda expression that you use with the interface must also have multiple parameters.

True

If a functional interface's abstract method is void, any lambda expression that you use with the interface should also be void T/F

"is a "

In OOP, inheritance is used to create a _____ relationship among classes

inheritance relationship

In a ________ relationship, the superclass constructor always executes before the subclass constructor

False

In an inheritance relationship the subclass inherits members from the superclass and visa versa T/F

False, superclass constructor always executes first

In an inheritance relationship, the subclass constructor always executes before the superclass constructor T/F

False

The "is a" relationship works in reverse T/F

False, not required, but recomended

The @override annotation is required when you override a method T/F

Object

The Java API has a class named ______, which all other classes directly or indirectly inherit from

Abstract Clss

The _____ represents the generic form of all of the classes that inherit from it .

superclass , subclass

The ______ constructor always executes before the ______ constructor

Throws clause

The ______ informs the compiler of the exceptions that could get thrown from a method

Multi-catch

The ability to catch multiple types of exceptions with a single catch clause is known as ______

The first statement

Where should the super statement that calls the superclass constructor be in the subclass's constructor?

Protected

______ members may be accessed by methods in the same package or in a subclass

constructors

_______ are not inherited because their purpose is to create objects of the superclass

The throw statement

_________ causes an exception object to be created and thrown

Unchecked exceptions

____________ are those that inherit from the Error class, or the RunTimeException class

RuntimeException

____________ serves as a superclass for exceptions that result from programming errors, such as an out-of-bounds array subscript

one abstract method

a functional interface is an interface that has ________

Interface

just as you can create reference variables of a class type, you can create reference variables of a _______ type

read or write

A random access file is a file that allows a program to ____ or ____ from any location within the file.

subclass

A reference variable of a superclass type can reference _______ objects

False, Override

A superclass that has an abstract method, the subclass must overload the method T/F

False

A class can only implement one interface, but may extend multiple superclasses. T/F

random access file

A _____________ is a file that allows a program to read data form any location within the file, or write data to any location within the file

Anonymous inner class

A ______________ is an inner class that has no name

False

A catch clause can only handle one type of exception T/F

functional interface

A lambda expressions creates an object that implements a _________

call stack

A stack trace is a list of all of the methods in the ________

False

A method in the subclass cannot overload a method in the superclass T/F

exception

A _____ is an object that is generated in memory as the result of an error or an unexpected event

default

A _____ method is an interface method that has a body

lambda expression

A ________ can access variables that are declared in the enclosing scope, as long as those variables are final, or effectively final

Exception handler

A ________ is a section of code that gracefully responds to exceptions when they are thrown

italics

Abstract classes are drawn like regular classes in UML, except the name of the class and the names of the abstract methods are written in ______

True

All exception objects have a printStackTrace method, inherited from the Throwable class, which can be used to print a stack trace T/F

Checked exceptions

All of the remaining exceptions (that is, those that do not inherit from Error or RuntimeException) are ___________

Flase

An Abstract class can be instantiated T/F

Inner class

An _____ is a class that is defined inside another class

False

An abstract class is instantiated T/F

False

An abstract class is instantiated and other classes inherit it. T/F

superclass

An abstract class is not instantiated itself, but it serves as a ________ for other classes.

extend

An abstract class is not instantiated, but other classes ______ it

True

An abstract class is not instantiated, but other classes extend it

Body

An abstract method cannot have _________. It must be overridden in a subclass

False

An abstract method has a header, and a body T/F

body

An abstract method has a header, but no _______

True

An abstract method is a method that appears in a superclass, but expects to be overriden in a subclass T/F

False

An abstract method should not be overriden in a subclass T/F

implement an innerface

An anonymous inner class must _________ or extend another class

(int x) -> {int a = x*2; return a;};

An example of a lambda expression with multiple statements in the body :

final and static

An interface can contains field declarations, but all fields in an interface are treated as _____ and _______

True

An interface reference variable can reference any object that implements that interface, regardless of class type T/F

True

Because an anonymous inner class's definition is written inside a method, it can access that method's local variables, but only if they are declared final, or are effectively final T/F

True

Beginning with Java 7 , a catch clause can handle more than one type of exception

(a,b) -> a+b;

Example of a lambda expression with two parameters:

dynamic binding, or late binding

Java performs ______ or ______ when a variable contains a polymorphic reference

lambda expressions

Like regular methods, ___________ can accept agruments and return values

False

New fields and methods may not be added to the subclass. T/F

Serialization

Object ________ is the process of converting an object to a series of bytes and saving them to a file

True

Overriding can only take place in an inheritance relationship

True

Private members of the superclass cannot be accessed by the subclass, so they are not inherited T/F

True

Private superclass members cannot be directly accessed by a method in a subclass T/F

subclass, package

Protected members of a class may be accessed by methods in a ______ and by methods in the same ______ as the class

binary file

The content of a ________ is not formatted as text, and not meant to be opened in a text editor

finally

The statements in the _____ block execute whether an exception occurs or not

False

The subclass inherits fields and methods from the superclass and rewrites them T/F

public or protected

The subclass must call a _______ or _______ superclass method in order to access the superclass's private members

instanceOf

There is an operator in Java named ________ that you can use to determine whether an object is an instance of a particular class.

abstract method

When a ________ appears in a class the method must be overriden in a subclass

instance

When a class contains an abstract method, you cannot create a _______ of the class

True

When a class implements an interface with a default method, the class can override the default method, but it is not required to. T/F

overrides

When a method ________ another method, they both have the same signature

final

When a method is declared with the ______ modifier, it cant be overridden in a subclass

public members

When a subclass extends a superclass, the public members of the superclass become________of the subclass.

True

When a subclass overloads a superclass method, both methods may be called with a subclass object. T/F

False

When a subclass overrides a superclass method, both versions of the method can be called with a subclass object. T/F

overriden

When an abstract method appears in a class the method must be ______ in a subclass

thrown

When an exception is generated it is said to have been _____

Thrown

When an exception is generated, it is said to have been ______

False

When an exception is thrown, it can be ignored T/F

polymorphic reference

When handling exceptions, you can use a ____________ as a parameter in the catch clause

Stack trace

When the exception occurs, the error message shows a ______ listing the methods that were called in order to produce the exception

package access

When you do not give a class member an access specifier, it is granted ______ access by default.

False

You can call the superclass constructor from any method T/F

Lambda expression

You can use a special type of expression, known as a _______ to create an object that implements a functional interface

super

You can use the _____ keyword to call a superclass constructor

True

You can use the throw statement to throw an exception manually T/F

True

You can write a super statement that calls a superclass constructor, but only in the subclass's constructor T/F

True

You can write multiple statements in the body of a lambda expression T/F

curly braces

You can write multiple statements in the body of a lambda expression, but if you do, you must enclose the statements in a set of _______ and you must write a return statement if the expression returns a value

semi-colon

You must terminate an abstract method's header with a ______

True

You should not handle unchecked exceptions T/F

Write data to a binary file

You wrap a DataOutputStream object around a FileOutputStream object to _________________

FileOutputStream object

You wrap a DataOutputStream object around a ________ to write data to a binary file

DataOutputStream object

You wrap a _______ around a FileOutputStream object to write data to a binary file

True

if a subclass constructor doesn't explicitly call a superclass constructor, java will automatically call super() just before the code in the subclass's constructor executes

Overloaded

if two methods have the same name, but different signatures,they are ________

signature

in order for overriding to occur, the subclass method must have the same ______ as the superclass method

overrides

A subclass may have a method with the same signature as a superclass method. In such a case, the subclass method _____ the superclass method

False

A superclass cannot inherit from another class

extend another class

An anonymous inner class must implement an interface, or __________

Exception

A _________ is an object that is generated as the result of an error or an unexpected event

abstract class

A ________ is not instantiated itself, but it serves as a superclass for other classes

Error Class

Unchecked exceptions are those that inherit from the ________

False

Unlike regular methods, lambda expressions cannot accept arguments or return values

Overloading

_____ is when a method has the same name as one or more other methods, but a different parameter list

Effectively final variable

A ________ is a variable whose value is never changed, but isn't declared with the final key word

Functional Interface

A __________ is an interface that has one abstract method

anonymous inner class

A compiler error will result if a _________ tries to use a variable that is not final, or not effectively final

final, or effectively final

A lambda express can access variables that are declared in the enclosing scope, as long as those variables are _______ or _________

final

If a subclass attempts to override a _____ method, the compiler generates an error

A constructor that the superclass does have

If a superclass doesn't have a default constructor, and doesn't have a no-arg constructor, then a class that inherits from it must call _______

Default, no-arg

If a superclass has either (a) a ____ constructor or (b) ________ constructor that was written into the class, then that constructor will automatically be called just before a subclass constructor executes

True

If the anonymous inner class extends a superclass, the superclass's no-arg constructor is called when the object is created

Never changed

An effectively final variable is a variable whose value is ________ , but isn't declared with the final key word

EOFException

An____object is thrown when an application attempts to read beyond the end of a file.

False, Vice versa

If you are handling multiple exceptions in the same try statement and some of the exceptions are related to each other through inheritance, then you should handle the more general exception classes before the more specialized exception classes. T/F

abstract methods

In its simplest form, an interface is like a class that contains only _______


Kaugnay na mga set ng pag-aaral

Chemistry Exam 2 (Chapter Ch. 3 -1/2Ch.4 )

View Set

Adding and subtracting complex numbers

View Set

The Acquisition and Maintenance of Phobias

View Set

Define total magnification, resolution, parfocal, field, depth of field, and, working distance

View Set