Java common face question 2015 (continuous update ... )

Source: Internet
Author: User

1. The difference between overwrite and overload

overload is an overload that declares a property or method with the same name as an existing member, but parameter list differs from original member . Override is primarily used for method overrides between the parent and child classes, that is, the specified property or method can be overridden in a derived class with the same argument list requirements . 
2. Class and Object differences  
Seems to like to ask, for example, the class represents a computer, his basic properties include CPU, memory, input, and objects represent some type of computer, such as Dell, Lenovo, HP, Apple Computer. A class is a common, abstract, or object that is specific to something.
3, HashMap and Hashtable differences
1) HashMap Inherits the parent class  Abstractmap,hashtable inherits the parent class dictionary
   
  
 
  1. public   class  hashtable  
  2.     extends  dictionary  
  3.     implements  map, cloneable,  Java.io.Serializable  
However HashMap is
  
 
  1. public   class  hashmap  
  2.     extends  abstractmap  
  3.     implements  map, cloneable,  Serializable  
2) HashMap Key/value can be empty, so thread is unsafe, key must be unique, value can not be unique; HashTable Key/value are not allowed to be empty, so threads are safe.
3) HashMap is not synchronized, while Hashtable is synchronous, multiple threads do not need to sync manually when accessing Hashtable, and HashMap need to provide external synchronization (COLLECTIONS.SYNCHRONIZEDMAP) 
 4 "hashtable   The Hash/rehash algorithm used by HashMap is probably the same, so there is no big difference in performance. 
4. Private default protected public scope
location Private default protected public
The same class Yes Yes Yes Yes
classes within the same package no Yes Yes Yes
subclasses in different packages no no no yes Yes
different packages and not subclasses no no no no Yes
To be continued in .....

Java common face question 2015 (continuous update ... )

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.