The second back of the Java plane question

Source: Internet
Author: User

1, the output of the following code is
 Packagetest;Importjava.util.Date; Public classSuperTestextendsdate{Private Static Final LongSerialversionuid = 1L; Private voidTest () {System.out.println (Super. GetClass (). GetName ()); }            Public Static voidMain (String[]args) {NewSuperTest (). Test (); } }

Answer: Test. SuperTest

The GetClass () in object, which is final modified and cannot be rewritten. therefore, the method in object is called. Returns the Object run-time class for this. The returned Class object is an object that is locked by the method of the represented class static synchronized . That is, the current class. Class.getname () returns the name of the entity (class, interface, array class, base type, or void) represented by this class object as a String .

If you want to get the name of the parent class, then Super.getclass (). Getsuperclass (). GetName ()

2, ArrayList list = new ArrayList (20), the list in the extension several times

A: The space size is specified at 0 initialization and is created directly. If not specified,ArrayList list = new ArrayList (), each expansion will increase by 1.5 times times plus 1

3, the following section of code, its operation result is
public class stringdemo{  private static final String message= "Taobao";  public static void Main (string [] args) {    string a = "Tao" + "Bao";    String b= "Tao";    String c= "Bao";    System.out.println (a==message);    System.out.println ((b+c) ==message);}  }

Answer: True False

4, the following code will print out
public static void Main (string[] args) {     String classfile = "com. JD.". ReplaceA11 (".", "/") + "Myclass.class";    System.out.println (classfile);}

Answer: In regular expressions. Represents any character

5, observe the following code output is:
Class Car extends vehicle{public    static void Main (string[] args)    {        new  car (). run ();    Private final void run ()    {        System. println ("Car");}    } Class vehicle{    private final void run ()    {        System. println ("Vehicle");}    }

A: The car parent class method has a private adornment, which is not visible for subclasses. So the method in the subclass is two methods

The second back of the Java plane question

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.