Unit 3 Two Truths & A Lie

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

Two of the following statements are true, and one is false. Identify the false statement:

a. ** A method's declared return type must match the type of the value used in the parameter list.** b. The return type for a method can be any type used in Java, including int, double, and void. c. You cannot place a method within another method, but you can call a method from within another method.

Two of the following statements are true, and one is false. Identify the false statement:

a. **A method header is also called an implementation.** b. Not all methods return a value, but every method requires a return type. c. When a method is declared with public access, methods in other classes can call it.

Two of the following statements are true, and one is false. Identify the false statement:

a. **In Java, you cannot write a default constructor; it must be supplied for you automatically.** b. The automatically supplied default constructor sets all numeric fields to 0, character fields to Unicode ' \u0000', Boolean fields to false, and fields that are object references to null. c. When you write a constructor, it must have the same name as the class it constructs, and it cannot have a return type.

Two of the following statements are true, and one is false. Identify the false statement:

a. **When you declare an object, you give it a name and set aside enough memory for the object to be stored.** b. When you don't write a constructor for a class, Java creates one for you; the name of the constructor is always the same as the name of its class. c. An object name is a reference; it holds a memory address.

Two of the following statements are true, and one is false. Identify the false statement:

a. An application or class that instantiates objects of another prewritten class is a class client. b. Objects gain their attributes and methods from their classes. c. **A class is an instantiation of many objects**

Two of the following statements are true, and one is false. Identify the false statement:

a. Arguments are used in method calls; they are passed to parameters in method headers. b. A class can contain any number of methods, and each method can be called any number of times. c. **A method header always contains a return type, an identifier, and a parameter list within parentheses.**

Two of the following statements are true, and one is false. Identify the false statement:

a. During one program execution, a method might be called any number of times. b. **A method is usually written within another method.** c. Any class can contain an unlimited number of methods.

Two of the following statements are true, and one is false. Identify the false statement:

a. Most fields in a class are private, and most methods are public. b. A class header contains an optional access specifier, the keyword class, and an identifier. c. **When you instantiate objects, each has its own copy of each static data field in the class.**

Two of the following statements are true, and one is false. Identify the false statement:

a. The address of an instantiated object can be assigned to a declared reference of the same type. b. **Unlike a primitive variable, an instantiated object cannot be passed into or returned from a method.** c. When you declare a primitive variable or instantiate an object from a class, you provide both a type and an identifier.

Two of the following statements are true, and one is false. Identify the false statement:

a. The keyword static is used with classwide methods, but not for methods that "belong" to objects. b. **Static methods are instance methods.** c. When you create a class from which objects will be instantiated, most methods are nonstatic because they are associated with individual objects.


Ensembles d'études connexes

Management 80 Chapter 9: International Financial Markets

View Set

Class 16 B - Disaster and Emergency Management

View Set

Anatomy & Biomechanics Final- Muscles

View Set

APUSH Chapter 2 - Europeans Encounter the New World

View Set