Quiz #3
Wednesday
With a piece of paper, write down your name and answers to the following questions.
Making an instance of one class a field in another class is called:
- Nesting
- Class Fielding
- Aggregation
- Concatenation
What
enummethod returns the position of anenumconstant in the declaration?positiontoStringlocationordinal
What is the name of the process, performed periodically by the JVM, that automatically removes unreferenced objects from memory?
- Memory Cleansing
- Memory Deallocation
- Garbage Collection
- Object Expungement
Is it necessary to override the
toStringmethod of anenumclass in order to obtain a string representation of the name of anenumconstant?Answer: No, it is not necessary.
What is the output of the following program?
public class Program { public static void main(String[] args) { MysteriousClass obj = new MysteriousClass(); obj.mysteriousPrint("def"); } } class MysteriousClass { private String arg = "abc"; public void mysteriousPrint(String arg) { System.out.println(arg); System.out.println(this.arg); } }Answer:
def
abc
Student Performance and Statistics
A histogram of student performance on percentage grades for Quiz 3 on Wednesday.
A table showing the average performance for each question in Quiz 3 on Wednesday.
Friday
With a piece of paper, write down your name and answers to the following questions.
What is the Java keyword that can be used to represent an instance of the class in which it appears and can be used to access class variables and methods?
methisthatself
What object collaboration relationship does the following UML diagram demonstrate?
- Nesting
- Aggregation
- Concatenation
- Class Fielding
Should class designers avoid returning references to mutable private fields because doing so may allow users of the class to adversely affect the internal state of an object?
Answer: Yes, they should avoid returning references to mutable private fields.
What is the output of the following program?
public class Program { public static void main(final String[] args) { System.out.println(Gender.Male); } } enum Gender { Confidential, Male, Female; }Answer:
Male
Student Performance and Statistics
A histogram of student performance on percentage grades for Quiz 3 on Friday.
A table showing the average performance for each question in Quiz 3 on Friday.