think in java interview-高级开发人员面试宝典(五)

简介: 这次开始我们来点洋文吧。有些基础,大家可能用中文知道如何表示,但是面试官如果让你用全英语表达你就不知道如何去说了,那么下面我们将给出对于一些常用的JAVA基础知识的英语问答以及相关的答案。




Overriding & Overloading

Overriding - same method names with same arguments and same return types associated in a class and its subclass. 

Overloading - same method name with different arguments, may or may not be same return type written in the same class itself.

What's the difference between an interface and an abstract class?

  • An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.
  • What’s the difference between Hashtable and Hashmap
  • They Both provide key-value access to data. 
  • The key difference between the two is that access to the Hashtable is synchronized on the table while access to the HashMap isn't. You can add it, but it isn't there by default.
  • Another difference is that iterator in the HashMap is fail-safe while the enumerator for the Hashtable isn't. 
  • And, a third difference is that HashMap permits null values in it, while Hashtable doesn't. 

What do you understand by Synchronization?

Synchronization is a process of controlling the access of shared resources by the multiple threads in such a manner that only one thread can access one resource at a time. In non synchronized multithreaded application, it is possible for one thread to modify a shared object while another thread is in the process of using or updating the object's value. Synchronization prevents such type of data corruption.

Synchronized statement and Synchronized block

Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method'sobject or class. Synchronized statements are similar to synchronized methods, always use synchronized(this) to instead of.

What is difference between jdbc3.0 and jdbc2.0? What’s the new features in jdbc3.0?


The JDBC 3.0 API introduces new material and changes in these areas:

1. Savepoint support
  Added the Savepoint interface, which contains new methods to set, release, or roll back a transaction to designated savepoints.

2. Reuse of prepared statements by connection pools

Added the ability for deployers to control how prepared statements are pooled and reused by connections.

3. Connection pool configuration Defined a number of properties for the ConnectionPoolDataSource interface.

These properties can be used to describe how pooledConnection objects created by DataSource objects should be pooled.

4. Retrieval of parameter metadata

Added the interface ParameterMetaData, which describes the number, type and properties of parameters to prepared statements.

5. Retrieval of auto-generated keys

Added a means of retrieving values from columns containing automatically generated values.

6.  Ability to have multiple open ResultSet objects

Added the new method getMoreResults(int), whichtakes an argument that specifies whether ResultSet objects returned by a Statement object should be closed before returning any subsequent ResultSet objects.

What's the difference between the methods sleep() and wait()


The code sleep(1000); puts thread aside for exactly one second. The code wait(1000), causes a wait of up to one second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread

What is oops

OOPs is the new concept of programming parallel to Procedure oriented programming
There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation
It help in programming approach in order to built robust user friendly and efficient softwares and provide the efficient way to maintain real world softwares..

What is Authentication & Authorization


Fundamentally, authentication is performed by a series of Spring Security filter (implementations of J2EE Servlet Filters) chains, linked together. Each element in a given chain has a dedicated responsibility, while each chain is responsible for accomplishing high-level goals towards the handling of a request. Ultimately, these chains must prepare a request to fulfill a single contract enforced by the last link in the primary security filter chain.


An authentication system is how you identify yourself to the computer. The goal behind an authentication system is to verify that the user is actually who they say they are. 
There are many ways of authenticating a user. Any combination of the following are good examples. 

Password based authentication 

Requires the user to know some predetermined quantity (their password). 
  • Advantages: Easy to impliemnt, requires no special equipemnt. 
  • Disadvantages: Easy to forget password. User can tell another user their password. Password can be written down. Password can be reused. 

Device based authentication 

Requires the user to posses some item such as a key, mag strip, card, s/key device, etc. 
  • Advantages: Difficult to copy. Cannot forget password. If used with a PIN is near useless if stolen. 
  • Disadvantages: Must have device to use service so the user might forget it at home. Easy target for theft. Still doesn't actually actively identify the user. 

Biometric Authentication 

  • My voice is my passport. Verify me. This is from the movie sneakers and demonstrates one type of biometric authentication device. It identifies some physical charactistic of the user that cannot be seperated from their body. 

Retina Scanners

  • Advantages: Accurately identifies the user when it works. 
  • Disadvantages: New technology that is still evolving. Not perfect yet. 

Hand Scanners 

  • Advantages: Difficult to seperate from the user. Accurately identifies the user. 
  • Disadvantages: Getting your hand stolen to break into a vault sucks a lot more than getting your ID card stolen. 


Once the system knows who the user is through authentication, authorization is how the system decides what the user can do. 
A good example of this is using group permissions or the difference between a normal user and the superuser on a unix system. 
There are other more compicated ACL (Access Control Lists) available to decide what a user can do and how they can do it. Most unix systems don't impliment this very well (if at all.) 

What is generic type?


When you take an element out of a Collection, you must cast it to the type of element that is stored in the collection. Besides being inconvenient, this is unsafe. The compiler does not check that your cast is the same as the collection's type, so the cast can fail at run time. 
Generics provides a way for you to communicate the type of a collection to the compiler, so that it can be checked. Once the compiler knows the element type of the collection, the compiler can check that you have used the collection consistently and can insert the correct casts on values being taken out of the collection. 

What is autoboxing and unboxing?


Autoboxing, introduced in Java 5, is the automatic conversion the Java compiler makes between the primitive (basic) types and their corresponding object wrapper classes (eg, int and Integer, double and Double, etc). The underlying code that is generated is the same, but autoboxing provides a sugar coating that avoids the tedious and hard-to-read casting typically required by Java Collections, which can not be used with primitive types.

What is equals() and hashcode()

又来了,具体原理和算法看:hashcode & equals之5重天

Java.lang.Object has methods called hasCode() and equals(). These methods play a significant role in the real time application. However its use is not always common to all applications. In some case these methods are overridden to perform certain purpose. In this article I will explain you some concept of these methods and why it becomes necessary to override these methods.

As you know this method provides the has code of an object. Basically the default implementation of hashCode() provided by Object is derived by mapping the memory address to an integer value. If look into the source of Object class , you will find the following code for the hashCode.
public native int hashCode();
It indicates that hashCode is the native implementation which provides the memory address to a certain extent. However it is possible to override the hashCode method in your implementation class. 

This particular method is used to make equal comparison between two objects. There are two types of comparisons in Java. One is using “= =” operator and another is “equals()”. I hope that you know the difference between this two. More specifically the “.equals()” refers to equivalence relations. So in broad sense you say that two objects are equivalent they satisfy the “equals()” condition. If you look into the source code of Object class you will find the following code for the equals() method


What is the Lazy Loading

Lazy loading in Hibernate means fetching and loading the data,    
only when it is needed, from a persistent storage like a database.     
Lazy loading improves the performance of data fetching and significantly reduces the memory footprint.
In Hibernate, there are two main components which can be lazy loaded. 
They are namely Entities and Collections. 
An Entity represents a relational data in database, whereas a collection represents collection of children for an entity.

What is MVC

Model–view–controller (MVC) is an architecturalpattern used in softwareengineering. Successful use of the pattern isolates business logic from user interface considerations, resulting inan application where it is easier to modify either the visual appearance of theapplication or the underlying business rules without affecting the other


Business logic goes here


Presentation logic goes here


Application logic goes here

What is Spring


The Spring Framework comprisesseveral modules that provide a range of services:

Why use hibernate

1. Hibernate generates very efficient queries very consistently

Hibernateemploys very agressive, and very intelligent first and second level cachingstrategy.

Thisis a major factor in acheiving the high scalability.

2. Cross-Database You only have to change the databasedialect.

What is dependency-injection

Software components (Clients), are often a part of a set of collaborating components which depend upon other components (Services) to successfully complete their intended purpose. In many scenarios, they need to know “which” components to communicate with, “where” to locate them, and “how” to communicate with them. When the way such services can be accessed is changed, such changes can potentially require the source of lot of clients to be changed.

One way of structuring the code is to let the clients embed the logic of locating and/or instantiating the services as a part of their usual logic. Another way to structure the code is to have the clients declare their dependency on services, and have some "external" piece of code assume the responsibility of locating and/or instantiating the services and simply supplying the relevant service references to the clients when needed.

What's difference between criterial query and hql:

Criteria is an object-oriented API, while HQL means string concatenation. That means all of the benefits of object-orientedness apply:
1. All else being equal, the OO version is somewhat less prone to error. Any old string could get appended into the HQL query, whereas only valid Criteria objects can make it into a Criteria tree. Effectively, the Criteria classes are more constrained.
2. With auto-complete, the OO is more discoverable (and thus easier to use, for me at least). You don't necessarily need to remember which parts of the query go where; the IDE can help you
3. You also don't need to remember the particulars of the syntax (like which symbols go where). All you need to know is how to call methods and create objects.
Since HQL is very much like SQL (which most devs know very well already) then these "don't have to remember" arguments don't carry as much weight. If HQL was more different, then this would be more importatnt.

Pls tell me the advantage points or new features of Spring FrameWork?

The Spring Framework comprises several modules that provide a range of services:

Inversion of Control container: configuration of application components and lifecycle management of Java objects

Aspect-oriented programming: enables implementation of cross-cutting routines
Data access: working with relational database management systems on the Java platform using JDBC and object-relational mapping tools

Transaction management: unifies several transaction management APIs and coordinates transactions for Java objects
Model-view-controller: an HTTP and Servlet-based framework providing hooks for extension and customization

Remote Access framework: configurative RPC-style export and import of Java objects over networks supporting RMI, CORBA and HTTP-based protocols including web services (SOAP)

Batch processing: a framework for high-volume processing featuring reusable functions including logging/tracing, transaction management, job processing statistics, job restart, skip, and resource management

Authentication and authorization: configurable security processes that support a range of standards, protocols, tools and practices via the Spring Security sub-project (formerly Acegi).
Remote Management: configurative exposure and management of Java objects for local or remote configuration via JMX

Messaging: configurative registration of message listener objects for transparent message consumption from message queues via JMS, improvement of message sending over standard JMS APIs

Testing: support classes for writing unit tests and integratio

What is spring transaction managerment?

Spring provides a consistent abstraction for transaction management. This abstraction is one of the most important of Spring's abstractions, and delivers the following benefits:
Provides a consistent programming model across different transaction APIs such as JTA, JDBC, Hibernate, iBATIS Database Layer and JDO.
Provides a simpler, easier to use, API for programmatic transaction management than most of these transaction APIs
Integrates with the Spring data access abstraction
Supports Spring declarative transaction management

the difference between BeanFactory and ApplicationContext ?

Two of the most fundamental and important packages in Spring are the org.springframework.beans and org.springframework.context packages. Code in these packages provides the basis for Spring's Inversion of Control (alternately called Dependency Injection) features. The BeanFactory provides an advanced configuration mechanism capable of managing beans (objects) of any nature, using potentially any kind of storage facility. The ApplicationContext builds on top of the BeanFactory (it's a subclass) and adds other functionality such as easier integration with Springs AOP features, message resource handling (for use in internationalization), event propagation, declarative mechanisms to create the ApplicationContext and optional parent contexts, and application-layer specific contexts such as the WebApplicationContext, among other enhancements.

Tell me what is AOP?

1. Aspect: A modularization of a concern that cuts across multiple objects. Transaction management is a good example of a crosscutting concern in J2EE applications.

2. Join point

3.  Advice

4.  Pointcut

5.  Introduction

6.  Target object

7.  Weaving

How many Types of advice are there in Spring Framework:

  •  Before advice
  •  After returning advice
  •  After throwing advice
  •  After (finally) advice
  • Around advice


Java 程序员
30 1
存储 Java 计算机视觉
25 0
Java 编译器 程序员
22 0
消息中间件 NoSQL 网络协议
Java 关系型数据库 MySQL
27 0
存储 缓存 算法
最重要的是保持自信和冷静。提前准备,并对自己的知识和经验有自信,这样您就能在面试中展现出最佳的表现。祝您面试顺利!Java 是一种广泛使用的面向对象编程语言,在软件开发领域有着重要的地位。Java 提供了丰富的库和强大的特性,适用于多种应用场景,包括企业应用、移动应用、嵌入式系统等。下是几个面试技巧:复习核心概念、熟悉常见问题、编码实践、项目经验准备、注意优缺点、积极参与互动、准备好问题问对方和知其所以然等,多准备最好轻松能举一反三。
45 0
Java 程序员 API
在Java 1.8版本中,引入了很多重要的新特性,这些特性常常成为面试的焦点
41 8
并行计算 安全 Java
【2月更文挑战第30天】 本文将深入探讨Java并发编程的核心概念和技术,包括线程、锁、同步、并发集合等。我们将从基础知识开始,逐步深入到高级主题,如Fork/Join框架、CompletableFuture和反应式编程。通过本文,你将能够理解并发编程的重要性,掌握Java中实现高效并发的关键技术和方法。
NoSQL Java 关系型数据库
安全 算法 Java
Java 并发编程 面试题及答案整理,最新面试题
Java 并发编程 面试题及答案整理,最新面试题
82 0