Skip to main content
留学咨询

辅导案例-TCSS 305

By May 15, 2020No Comments

University of Washington, Tacoma TCSS 305 Winter 2020 Final Exam Sample Important Topics: • Interface • Inheritance • Equals, HashCode • Encapsulation Violation • Clone • Swing Timers • 2D Graphics • Streams 1. How will you address Encapsulation Violation (if present)? public final class MyClass { private final Point myPoint; private final Integer[] myIntegerList; public MyClass(final Point thePoint, final Integer[] theIntegerList) { myPoint = thePoint; myIntegerList = theIntegerList; } public Point getPoint() { return myPoint; } public Integer[] getIntegerList() { return myIntegerList; } } 2. Equals and HashCode: i. Does hashcode return the memory address? ii. What does obj1 == obj2 compare? iii. Calling obj1.equals(obj2) when obj2 is null throws an error? 3. Give 5 examples of immutable objects in JAVA 4. 2D Graphics a. Create a drawing Panel which extends paint panel b. Inside the paintComponent create a rectangle starting from 100,100 and with dimensions 100, 100 c. Draw an ellipse inside the rectangle of dimension 20, 20 inside the reactangle d. Draw a filled square inside the rectangle of dimension 10, 10 without overlapping with the ellipse e. Why do we should not call repaint() inside paintComponent? 5. Use Streams to generate 0, 1, 1, 4, 25,….. upto 10 numbers 6. Timers Timer myTimer = new Timer(2000, myActionListener); myTimer.setInitialDelay(3000); myTimer.start(); List the time when myActionListener will be called?

admin

Author admin

More posts by admin