Java and C common technical interview questions 2015 (Continuous updates ...), 2015 updating

Source: Internet
Author: User
Tags finally block

Java and C common technical interview questions 2015 (Continuous updates ...), 2015 updating

1. Differences between overwrite and overload

Overload is an Overload. It uses the same name as an existing member to declare attributes or methods, but the parameter list is different from that of the original member. Override is mainly used for method rewriting between the parent class and the subclass, that is, the specified attribute or method can be rewritten in the derived class, and its parameter list must be the same.
2. Differences between classes and objects
For example, a class represents a computer. Its basic attributes include cpu, memory, and input/output devices. An object represents a type of computer, such as Dell, Lenovo, HP, and apple. Classes are common and abstract; objects are specific things.
3. Differences between HashMap and HashTable
1) hashMap inherits the parent class AbstractMap, and 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 the thread is not secure. The key must be unique and the value can be unique. HashTable key/value cannot be empty, so the thread is secure.
3) hashMap is not synchronized, while hashTable is synchronized. manual synchronization is not required when multiple threads access hashTable, and hashMap must provide external synchronization (Collections. synchronizedMap)
4) the hash/rehash algorithms used by Hashtable and HashMap are roughly the same, so there will be no major performance difference.
4. private default protected public Scope
Location private default protected public
The same class is
Whether the class in the same package is yes or not
Subclass in different packages? No Yes
Different packages and not subclass No Yes
5. What is the relationship between collection, map, set, list, hashMap, hashTable, TreeMap, AbstractMap, HashSet, TreeSet, AbstractSet, ArrayList, Vector, and shortlist?
A figure to explain the mysteries:
For more information about ArrayList, HashMap, and HashTable features, click here

6. Memory heap and stack memory are released

1) stack: the compiler automatically allocates and releases the stack, stores the function parameter values, and values of local variables. The operation method is similar to the stack in the data structure.

2) heap: usually assigned and released by programmers, such as c/c ++, malloc/new, and free/delete. If the programmer does not release the program, it may be recycled by the OS at the end of the program. Note that it is different from the heap in the data structure. The allocation method is similar to the linked list.

3) Global (static): the storage of global and static variables is placed in one area, and the initialized global and static variables are in one area, uninitialized global variables and uninitialized static variables are in another adjacent area. After the program ends, the system is released.

4) text Constant Area: constant strings are placed here. The program is released by the system.

5) program code area: stores the binary code of the function body.


Here: I want to know more about the difference between stack and stack.

The storage method is shown in:


Image Source


To be continued .....


Java FAQ

Download a java interview book online with comprehensive questions.

What are the correct answers to common Java programming interview questions?

First, let's talk about the differences between final, finally, and finalize.

Final? Modifier (keyword) If a class is declared as final, it means that it cannot generate a new subclass and cannot be inherited as a parent class. Therefore, a class cannot be declared both abstract and final. Declare variables or methods as final to ensure that they are not changed during use. Variables declared as final must be declared with an initial value, which can only be read and cannot be modified in future references. Methods declared as final can only be used, but cannot be used to reload finally? Finally blocks are provided for troubleshooting. If an exception is thrown, the matched catch clause is executed, and the control enters the finally block (if any ).

Finalize? Method Name. Java technology allows you to use the finalize () method to clear objects from the memory before the Garbage Collector clears them. This method is called by the garbage collector when it determines that this object is not referenced. It is defined in the Object class, so all classes inherit it. Subclass overwrites the finalize () method to sort system resources or perform other cleanup tasks. The finalize () method is called before the Garbage Collector deletes an object.

Second, can Anonymous Inner Class (Anonymous internal Class) be extends (inherited) other classes, or implements (implemented) interface (interface )?

An anonymous internal class is an internal class without a name. It cannot be extends (inherited) other classes, but an internal class can be used as an interface and implemented by another internal class.

Third, the difference between Static Nested Class and Inner Class is that the more you say, the better (the more general the interview questions are ).

Nested Class (generally C ++) and Inner Class (generally JAVA ). The biggest difference between Java internal classes and C ++ Nested classes is whether there are external references. For details, see http: // www.frontfree.net/..page00001.

Note: The static internal Class (Inner Class) means that 1 creates an object of the static internal Class and does not need an external Class object, 2. You cannot access an external class object from an object of a static internal class.

Fourth, the difference between & and.

& Is a bitwise operator. & Is a Boolean logical operator.

Fifth, the difference between HashMap and Hashtable.

All belong to the Map interface class, which maps the unique key to a specific value.

The HashMap class is not classified or sorted. It allows a null key and multiple null values.

Hashtable is similar to HashMap, but does not allow null keys and null values. It is also slower than HashMap because it is synchronized.

Sixth, the difference between Collection and Collections.

Collections is a java. util class that contains various static methods related to set operations.
Collection is an interface under java. util. It is the parent interface of various Collection structures.

7. When to use assert.

Assertion is a statement containing a Boolean expression. When executing this statement, it is assumed that the expression is... the remaining full text>

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.