CRC CISP 401 Java Quiz 7

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which of the following statements about interfaces is false? 1) An interface describes a set of methods that can be called on an object, providing a default implementation for the methods. 2) An interface describes a set of methods that can be called on an object, not providing concrete implementation for the methods. 3) Interfaces are useful when attempting to assign common functionality to possibly unrelated classes. 4) Once a class implements an interface, all objects of that class have an is-a relationship with the interface type.

1) An interface describes a set of methods that can be called on an object, providing a default implementation for the methods.

All of the following methods are implicitly final except: 1) a method in an abstract class. 2) a private method. 3) a method declared in a final class. 4) static method.

1) a method in an abstract class.

Which of the following statements about abstract superclasses is true? 1) abstract superclasses may contain data. 2) abstract superclasses may not contain implementations of methods. 3) abstract superclasses must declare all methods as abstract. 4) abstract superclasses must declare all data members not given values as abstract.

1) abstract superclasses may contain data.

Polymorphism allows for specifics to be dealt with during: 1) execution. 2) compilation. 3) programming. 4) debugging.

1) execution.

Every object in Java knows its own class and can access this information through method. 1) getClass. 2) getInformation. 3) objectClass. 4) objectInformation.

1) getClass.

Polymorphism enables you to: 1) program in the general. 2) program in the specific. 3) absorb attributes and behavior from previous classes. 4) hide information from the user.

1) program in the general.

Which of the following is not possible? 1) A class that implements two interfaces. 2) A class that inherits from two classes. 3) A class that inherits from one class, and implements an interface. 4) All of the above are possible.

2) A class that inherits from two classes.

Assigning a subclass reference to a superclass variable is safe: 1) because the subclass object has an object of its superclass. 2) because the subclass object is an object of its superclass. 3) only when the superclass is abstract. 4) only when the superclass is concrete.

2) because the subclass object is an object of its superclass.

Which keyword is used to specify that a class will define the methods of an interface? 1) uses. 2) implements. 3) defines. 4) extends.

2) implements.

If the superclass contains only abstract method declarations, the superclass is used for: 1) implementation inheritance. 2) interface inheritance. 3) Both. 4) Neither.

2) interface inheritance.

It is a UML convention to denote the name of an abstract class in: 1) bold. 2) italics. 3) a diamond. 4) there is no convention of the UML to denote abstract classes—they are listed just as any other class.

2) italics.

For which of the following would polymorphism not provide a clean solution? 1) A billing program where there is a variety of client types that are billed with different fee structures. 2) A maintenance log program where data for a variety of types of machines is collected and maintenance schedules are produced for each machine based on the data collected. 3) A program to compute a 5% savings account interest for a variety of clients. 4) An IRS program that maintains information on a variety of taxpayers and determines who to audit based on criteria for classes of taxpayers.

3) A program to compute a 5% savings account interest for a variety of clients.

A class that implements an interface but does not declare all of the interface's methods must be declared: 1) public. 2) interface. 3) abstract. 4) final.

3) abstract.

A(n) class cannot be instantiated. 1) final. 2) concrete. 3) abstract. 4) polymorphic.

3) abstract.

Classes and methods are declared final for all but the following reasons: 1) final methods allow inlining the code. 2) final methods and classes prevent further inheritance. 3) final methods are static. 4) final methods can improve performance.

3) final methods are static.

The UML distinguishes an interface from other classes by placing the word "interface" in above the interface name. 1) italics. 2) carets. 3) guillemets. 4) bold.

3) guillemets.

Which of the following could be used to declare abstract method method1 in abstract class Class1 (method1 returns an int and takes no arguments)? 1) public int method1(); 2) public int abstract method1(); 3) public abstract int method1(); 4) public int nonfinal method1();

3) public abstract int method1();

An interface may contain: 1) private static data and public abstract methods. 2) only public abstract methods. 3) public static final data and public abstract methods. 4) private static data and public final methods.

3) public static final data and public abstract methods.

Which statement best describes the relationship between superclass and subclass types? 1) A subclass reference cannot be assigned to a superclass variable and a superclass reference cannot be assigned to a subclass variable. 2) A subclass reference can be assigned to a superclass variable and a superclass reference can be assigned to a subclass variable. 3) A superclass reference can be assigned to a subclass variable, but a subclass reference cannot be assigned to a superclass variable. 4) A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.

4) A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.

Consider the abstract superclass below: public abstract class Foo { private int a; public int b; public Foo( int aVal, int bVal ) { a = aVal; b = bVal; } // end Foo constructor public abstract int calculate(); } // end class Foo Any concrete subclass that extends class Foo: 1) Must implement a method called calculate. 2) Will not be able to access the instance variable a. 3) Neither (a) nor (b). 4) Both (a) and (b).

4) Both (a) and (b).

Consider classes A, B and C, where A is an abstract superclass, B is a concrete class that inherits from A and C is a concrete class that inherits from B. Class A declares abstract method originalMethod, implemented in class B. Which of the following statements is true of class C? 1) Method originalMethod cannot be overridden in class C—once it has been implemented in concrete class B, it is implicitly final. 2) Method originalMethod must be overridden in class C, or a syntax error will occur. 3) If method originalMethod is not overridden in class C but is called by an object of class C, an error occurs. 4) None of the above.

4) None of the above.

Interfaces can have methods. 1) 0 2) 1 3) 2 4) any number of

4) any number of

Which of the following does not complete the sentence correctly? An interface . 1) forces classes that implement it to declare all the interface methods. 2) can be used in place of an abstract class when there is no default implementation to inherit. 3) is declared in a file by itself and is saved in a file with the same name as the interface followed by the .java extension. 4) can be instantiated.

4) can be instantiated.

Non-abstract classes are called: 1) real classes. 2) instance classes. 3) implementable classes. 4) concrete classes.

4) concrete classes.

Declaring a method final means: 1) it will prepare the object for garbage collection. 2) it cannot be accessed from outside its class. 3) it cannot be overloaded. 4) it cannot be overridden.

4) it cannot be overridden.

When a superclass variable refers to a subclass object and a method is called on that object, the proper implementation is determined at execution time. What is the process of determining the correct method to call? 1) early binding. 2) non-binding. 3) on-time binding. 4) late binding.

4) late binding.


Ensembles d'études connexes

Intro to Axial Skeleton, Cranial Bones, Sutures Between Cranial Bones, Facial Bones, Surface features of the skull, Composite structures, Passageways, The Sinuses and the Hyoid, The Vertebral Column, Thoracic Cage

View Set

clicker questions for chapter 5,6,7,8

View Set

Economics 202 online Test 3 TAMU

View Set