Variables should be declared as fields only if a. they are required for use in m
ID: 3694415 • Letter: V
Question
Variables should be declared as fields only if a. they are required for use in more than one method or their values must be b. they are local variables. c. they are arguments. d. they are used only within a method. 4. Placing items into the public interface of a class means a. only objects of the class itself can see and use them. b. any class that uses objects of the class can see and use them. c. they must be implemented as static methods and fields. d. they will not be listed in the UML specification. 5. A class is a. an object. b. an executable piece of code. c. an abstract template of an object. d. a variable. 6. What is the role of the constructor? a. Create an instance of a class (an object) b. Create names for methods c. To create buildings for coffee houses d. To release memory for other processesExplanation / Answer
Answer:
3. a)
Variables are declared as fields in a class only if they are required to be used
in more than one method so that name conflicts dont occur.
4. a)
We declare anythng in public section so that the objects of the class can directly access it
6. a
The role of a constructor is to initialise the objects of the class.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.