Quiz #3

Wednesday

With a piece of paper, write down your name and answers to the following questions.

  1. Making an instance of one class a field in another class is called:

    1. Nesting
    2. Class Fielding
    3. Aggregation
    4. Concatenation
  2. What enum method returns the position of an enum constant in the declaration?

    1. position
    2. toString
    3. location
    4. ordinal
  3. What is the name of the process, performed periodically by the JVM, that automatically removes unreferenced objects from memory?

    1. Memory Cleansing
    2. Memory Deallocation
    3. Garbage Collection
    4. Object Expungement
  4. Is it necessary to override the toString method of an enum class in order to obtain a string representation of the name of an enum constant?

    Answer: No, it is not necessary.

  5. 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.

100% 2 90 - 99% 0 80 - 89% 6 70 - 79% 0 60 - 69% 6 50 - 59% 0 40 - 49% 3 30 - 39% 0 20 - 29% 1 10 - 19% 0 0 - 9% 0

A table showing the average performance for each question in Quiz 3 on Wednesday.

Q1 0.8 / 1 Q2 0.4 / 1 Q3 0.9 / 1 Q4 0.6 / 1 Q5 0.6 / 1

Friday

With a piece of paper, write down your name and answers to the following questions.

  1. 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?

    1. me
    2. this
    3. that
    4. self
  2. What object collaboration relationship does the following UML diagram demonstrate?

    Class Diagram

    1. Nesting
    2. Aggregation
    3. Concatenation
    4. Class Fielding
  3. 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.

  4. 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.

100% 3 90 - 99% 0 80 - 89% 0 70 - 79% 2 60 - 69% 0 50 - 59% 2 40 - 49% 0 30 - 39% 0 20 - 29% 1 10 - 19% 0 0 - 9% 0

A table showing the average performance for each question in Quiz 3 on Friday.

Q1 0.8 / 1 Q2 0.6 / 1 Q3 0.8 / 1 Q4 0.8 / 1