Midterm Part 1

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

A class is not an object. It is a description of an object. (true/false)

true

If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method (true/false)

true

In a try statement, the try clause must appear first, followed by all of the catch clauses, followed by the optional finally clause (true/false)

true

When an object is passed as an argument to a method, what is passed into the method's parameter variable? a. the method names b. the class names c. the object's memory address d. the values for each field

c. the object's memory address

Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by: a. using the public access specifier on the class methods b. using the private access specifier on the class definition c. using the private access specifier on the class methods d. using the private access specifier on the class fields

d. using the private access specifier on the class fields

If ClassC is derived from ClassB, which is derived from ClassA, this would be an example of: a. cascading classes b. multiple interfaces c. linear inheritance d. a chain of inheritance

d. a chain of inheritance

A ____ member's access is somewhere between public and private. a. package b. final c. static d. protected

d. protected

The public access specifier for a field indicates that the field may not be accessed by statements outside the class (true/false)

false

Instance methods do not have the key word static in their headers (true/false)

true

It is not possible for a superclass to call a subclass's method (true/false)

true

A subclass can directly access: a. only protected and private members of the superclass b. only public and protected members of the superclass c. all members of the superclass d. only public and private members of the superclass

b. only public and protected members of the superclass

The scope of a private instance field is: a. the method in which it is defined b. the instance methods of the same class c. inside the parentheses of a method header d. inside the class but not inside any method in that class

b. the instance methods of the same class

To compare two objects in a class: a. this cannot be done since objects consist of several fields b. write an equals method that will make a field by field compare of the two objects c. write a method to do a byte-by-byte compare of the two objects d. use the == operator (for example, object1 == object2)

b. write an equals method that will make a field by field compare of the two objects

When a method is declared with the ________ modifier, it cannot be overridden in a subclass. a. super b. public c. final d. void

c. final

What tells the Java compiler that a method is meant to override a method in the superclass? a. @Protected b. @Overload c. @Inherited d. @Override

d. @Override

When a field is declared static there will be: a. two reference copies of the field for each method in the class b. a copy of the field in each class object c. a copy of the field for each method in the class d. only one copy of the field in memory

d. only one copy of the field in memory

Recursion is never absolutely required to solve a problem (true/false)

true

The term "no-arg constructor" is applied to any constructor that does not accept arguments (true/false)

true

Which of the following is true about protected access? a. Protected members may be accessed by methods in the same package or in a subclass, but only if the subclass is in the same package b. Protected members may be accessed by methods in the same package or in a subclass, even when the subclass is in a different package c. Protected members are actually named constants d. Protected members cannot be accessed by methods in any other classes

a. Protected members may be accessed by methods in the same package or in a subclass, but only if the subclass is in the same package

Which key word indicates that a class inherits from another class? a. extends b. final c. implements d. super

a. extends

A deep copy of an object: a. is an operation that copies an aggregate object and all the objects that it references b. is an assignment of that object to another object c. is a bogus term and means nothing d. is always a private method

a. is an operation that copies an aggregate object and all the objects that it references

Most of the programming languages used today are: a. object-oriented b. top-down c. procedural d. functional

a. object-oriented

The ________ key word is used to call a superclass constructor explicitly. a. super b. extends c. this d. goto

a. super

All fields declared in an interface: a. have private access b. are treated as final and static c. have protected access d. must be initialized in the class implementing the interface

b. are treated as final and static

A class specifies the ________ and ________ that a particular type of object has. a. relationships, methods b. fields, methods c. fields, object names d. relationships, object names

b. fields, methods


Set pelajaran terkait

Nutrition and Health GWC Prof. Shipp

View Set

Psych 6.2 Classical Conditioning

View Set

Altered Immune Response and Transplantation

View Set

Volume of Pyramids Assignment and Quiz

View Set

Med Surg - Chapter 59 - Care of Patients with Problems of the Biliary System and Pancreas

View Set

Chapter 8 & Appendix J exam review

View Set

Romanticism ca. 1780-1880, Realism, Late 19th C HOA106 Test two

View Set