20165209 2017-2018-2 "Java Programming" 7th Week study Summary

Source: Internet
Author: User
Tags shallow copy throwable

20165209 2017-2018-2 "Java program Design" 7th Week Study summary Textbook study summary
    • Install the EAMPP and complete the configuration
    • EAMPP Connection Database
    • Create a database
    • Learn to query operations
Problems in teaching materials learning and the solving process
    • Issue 1: The following error occurred while initializing MySQL
mysqld: Could not create or access the registry key needed for the MySQL applicationto log to the Windows EventLog. Run the application with sufficientprivileges once to create the key, add the key manually, or turn offlogging for that application.
    • Issue 1 Solution: Re-run cmd as Administrator and enter ' Mysqld--initialize-insecure.
Code Hosting

Last week's summary of the wrong quiz

1. The following statement about the inner class is right for ABD

A. No other class can declare an object with an inner class of a class.
B. The name format of the internal class bytecode file is "outer-nested class name $ internal class name".
C. The class body of an inner class can declare class variables and class methods.
D. The inner class is in the member position, so it can be decorated by private.

    • Analytical:
      C: Class variables and class methods cannot be declared in the class body of an inner class.
      D. Internal classes cannot use private adornments and are always controlled by access rights.
    1. The following class cannot be compiled, and the third line has an error message because the class cannot be modified by static. B

          class Outer{int x = 3;static class Inner{void function() {System.out.println(x);}}}
      A. True
      B. False
    • Resolution: The fifth line appears with an error message. Inner classes can be modified by static. When an inner class is modified by static, only the static members of the outer class can be accessed directly.

3. “byte[] arr=new byte[1024*1024*600];” Java.lang.OutOfMemoryError exception will be thrown if it exceeds the JVM's ability to run. (False)

    • Parsing: For serious errors, described by the error class, and for non-serious problems, it is described by the exception class.

4. The following cannot be used in the throw statement is C

A. Error
B. RuntimeException
C. Object
D. Throwable
E. Exception

    • Parse: A simple type, such as an int or char, and a non-throwable class, such as a string or object, cannot be used as an exception.

5. The following statement is correct for a B D

A. You can use the FileOutputStream class to write to a file.
B. The FileOutputStream class is constructed by FileOutputStream (file file), FileOutputStream (String name), FileOutputStream (file file, Boolean append) and so on.
C. For the FileOutputStream (String name) method, the file specified by the parameter name is called the source of the output stream.
D. If the output stream points to a file that already exists, the output stream refreshes the file so that the length of the file is 0.

    • Parse: The file specified by the parameter name is called the destination of the output stream.

6. The following about HashMap

A. public boolean IsEmpty () returns True if this mapping does not contain a key-value mapping relationship.
B. Public V get (Object key) returns the value mapped by the specified key, or throws an exception if the mapping does not contain a mapping relationship for the key.
C. Public V put (K key, V value) associates the specified value with the specified key in this mapping. If the map previously contained a mapping of the key, the values defined first prevail.
D. Public Object Clone () returns a shallow copy of this HASHMAP instance: The key and the value itself are not copied.

    • Analytical:
      B: If this mapping does not contain a mapping relationship for the key, NULL is returned.
      C: If the map previously contained a mapping of the key, the old value is replaced.

7. The following about TreeSet

A. Public Boolean contains (Object o) returns True if this set contains the specified element. Returns False if the specified object cannot be compared with the current element in the set, or is not included.
B. The public boolean add (e E) Adds the specified element to this set. If this set already contains such an element, the call does not change this set and returns FALSE.
C. public boolean addall (collection<? extends e> c) adds all the elements in the specified Collection to this set. Returns True if this set is changed because of a call.
D. Public e Lower (e e) returns the largest element in this set that is strictly less than the given element, or null if no such element exists.

    • Analytical:
      A: If the specified object cannot be compared with the current element in the set, the ClassCastException exception is thrown.

8. If the object stored in the list is not string data, the class that created the object must implement the comparable interface. (True)

9. The following statement on the substring method is correct. A C D

A. public string substring (int beginindex) returns a substring starting at the character at the specified index until the end of this string.
B. The public string substring (int beginindex, int endIndex) substring starts at the specified beginindex until the character at the index EndIndex.
C. "Emptiness". Substring (9) The return value is "".
D. "Smiles". Substring (1, 5) The return value is "mile".
E. If Beginindex is greater than endIndex, then substring (int beginindex, int endIndex) returns-1.

    • Analytical:
      B: The character at the index endIndex-1.
      E: Throws a Indexoutofboundsexception exception.

10. The following statement about the math class is correct for a B D

A. public static double CBRT (double A) returns the cube root of a double value. If the argument is Nan, the result is Nan.
B. public static double cos (double A) returns the trigonometric cosine of the angle. If the argument is Nan or infinity, the result is Nan.
C. public static double floor (double a) returns the largest (closest to positive infinity) Double value, which is less than or equal to the parameter and equals an integer. If the argument is Nan or infinity, the result is Nan.
D. public static double log10 (double A) returns the logarithm of the base 10 of the double value. If the parameter is positive 0 or minus 0, then the result is negative infinity.

    • Analytical:
      C: If the parameter is NaN, infinity, positive 0, or minus 0, then the result is the same as the parameter.
Learning progress Bar
lines of code (new/cumulative) Blog Volume (Add/accumulate) Learning Time (new/cumulative) Important Growth
Goal 5000 rows 30 Articles 400 hours
First week 37/37 1/1 20/20
Second week 654/691 3/4 18/38
Third week 477/1131 3/7 22/60
Week Four 657/1730 2/9 30/90
Week Five 1260/2515 1/10 30/120
Week Six 1022/3319 2/12 20/140
Seventh Week 1213/3803 1/13 20/160
Resources
    • Java2 Practical Tutorial (5th Edition)
    • Intellj Idea Easy Tutorial

20165209 2017-2018-2 "Java Programming" 7th Week study Summary

Related Article

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.