201521123089 Java Programming 6th Week of study summary

Source: Internet
Author: User

1. Summary of this Week's study

2. written work
  1. Clone method
    1.1 Object in thecloneMethod is modified by protected, What do you need to be aware of when overriding the Clone method in your custom class? Answer: Obje In CT Objects.the Clone method is protected decorated, and if you want to overwrite the clone method in a subclass, the method is modified by public .
    1.2 When you design your own class, what kind of method is generally used to modify the protected? To workShapeFor illustrative Examples. For:protected modified variables, subclasses can directly access the parent class members or quilt class Overrides. In shape, The amount of abstraction associated with a graph, such as the length and width, can be used Protected.
    1.3 Write simple in the Test1 packageEmployeeclass, create a new one in the Test2 packageTestProtectedclass, and in main, try to invoke the Clone method of the employee in the Test1 package to clone a new object, can it be successful? A: It cannot succeed because the employee class and the Testprotected class are not in the same package, nor are they inheritance relationships.

  2. Using anonymous classes and lambda expressions to rewrite the title object 2-advanced-polymorphic interface Inner class topic 5-2
    only need to paste the key code and run the result, the picture is not too big.                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp             Answer:

  3. Analyze the following code to answer shapeComparator what does the object pointed to have to do with the comparator interface?

    Comparator<Shape> shapeComparator = new  Comparator<Shape>() {       @Override       public int compare(Shape o1, Shape o2) { //你的代码 } };答:shapeComparator所指向的对象只是为了实现Comparator接口,让这个对象可以用Arrays.sort()方法排序。
  4. Event handling in the GUI
    4.1 Write out the most important keywords in the event-handling model. Answer: event, Event source, Event Listener
    4.2 Use code and annotations to prove that you understand the event-handling model. For:

    PublicClassEventObjectImplementsJava.Io.Serializable {ProtectedTransient Object source;PublicEventObject(Object source);Public ObjectGetSource();Get Event SourcePublic StringTostring(); }public class Maingui {PublicStaticvoidMain(string[] Args) {JFrame f =New JFrame ("Test");Create an event template F.setdefaultcloseoperation (jframe.exit_on_close); JButton B =New JButton ("press me!");Event Source B.addactionlistener (New Buttonhandler ()); //register Event Listener f.add (b); f.setsize (+ ); f.setvisible (true);} private static class Buttonhandler implements actionlistener{//listener  public void actionperformed(actionevent e) {System.out.println ("Action occurred"); System.out.println (e.getsource ()); //get Event source}}} 
    3. Code submission record on code Cloud and PTA Experiment Summary
  5. Pair programming: object-oriented Design (big job 2-very important, unfinished-2)
    Continue to refine last Week's project Assignments. The assessment points are as follows:
    5.1 Try overwriting using the graphical interface.
    5.2 Gives a record of the same item on the code cloud for two People.
    5.3 What are the major changes to the project compared to last week?

Resources:
Pair programming Reference
Drawing with ProcessOn
Video-writing a GUI with NetBeans
Important: Swing Experimental Reference
JTable usage, for rendering tabular data
Swing related articles

3. Code submission record on code Cloud and PTA Experiment Summary

Topic set: jmu-java-04-object-oriented 2-advanced-polymorphic Interface Inner class

3.1. Code cloud codes submission record
    • In the code cloud project, Select Statistics-commits history-set time period, and then search for and
3.2. PTA Experiment

             1. learned to define Interfaces.                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                 &NBSp                          ,         &NB Sp  2. Learn how to create a static inner class and its methods inside a class.

201521123089 Java Programming 6th Week of study summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.