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

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

这次开始我们来点洋文吧。

有些基础,大家可能用中文知道如何表示,但是面试官如果让你用全英语表达你就不知道如何去说了,那么下面我们将给出对于一些常用的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?

这道题可见老外的面试对基础是多么的重视,回答时掌握好6点


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

这道题很猛,来自于Oracle的一次面试。

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.


Authentication 

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. 

Authorization 

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.

hashCode()
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. 

equals()
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


下面开始来几道J2EE的面试题


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

Model

Business logic goes here

View

Presentation logic goes here

Controller

Application logic goes here


What is Spring

Springfeature:

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

每篇不宜写过多,先写这么多吧,下次继续,嘿嘿!!!

目录
相关文章
|
7天前
|
监控 Java 应用服务中间件
高级java面试---spring.factories文件的解析源码API机制
【11月更文挑战第20天】Spring Boot是一个用于快速构建基于Spring框架的应用程序的开源框架。它通过自动配置、起步依赖和内嵌服务器等特性,极大地简化了Spring应用的开发和部署过程。本文将深入探讨Spring Boot的背景历史、业务场景、功能点以及底层原理,并通过Java代码手写模拟Spring Boot的启动过程,特别是spring.factories文件的解析源码API机制。
25 2
|
12天前
|
存储 算法 Java
大厂面试高频:什么是自旋锁?Java 实现自旋锁的原理?
本文详解自旋锁的概念、优缺点、使用场景及Java实现。关注【mikechen的互联网架构】,10年+BAT架构经验倾囊相授。
大厂面试高频:什么是自旋锁?Java 实现自旋锁的原理?
|
17天前
|
存储 缓存 Oracle
Java I/O流面试之道
NIO的出现在于提高IO的速度,它相比传统的输入/输出流速度更快。NIO通过管道Channel和缓冲器Buffer来处理数据,可以把管道当成一个矿藏,缓冲器就是矿藏里的卡车。程序通过管道里的缓冲器进行数据交互,而不直接处理数据。程序要么从缓冲器获取数据,要么输入数据到缓冲器。
Java I/O流面试之道
|
14天前
|
存储 缓存 Java
大厂面试必看!Java基本数据类型和包装类的那些坑
本文介绍了Java中的基本数据类型和包装类,包括整数类型、浮点数类型、字符类型和布尔类型。详细讲解了每种类型的特性和应用场景,并探讨了包装类的引入原因、装箱与拆箱机制以及缓存机制。最后总结了面试中常见的相关考点,帮助读者更好地理解和应对面试中的问题。
39 4
|
15天前
|
存储 Java 程序员
Java基础的灵魂——Object类方法详解(社招面试不踩坑)
本文介绍了Java中`Object`类的几个重要方法,包括`toString`、`equals`、`hashCode`、`finalize`、`clone`、`getClass`、`notify`和`wait`。这些方法是面试中的常考点,掌握它们有助于理解Java对象的行为和实现多线程编程。作者通过具体示例和应用场景,详细解析了每个方法的作用和重写技巧,帮助读者更好地应对面试和技术开发。
55 4
|
25天前
|
算法 Java
JAVA 二叉树面试题
JAVA 二叉树面试题
14 0
|
3月前
|
存储 Java
【IO面试题 四】、介绍一下Java的序列化与反序列化
Java的序列化与反序列化允许对象通过实现Serializable接口转换成字节序列并存储或传输,之后可以通过ObjectInputStream和ObjectOutputStream的方法将这些字节序列恢复成对象。
|
1月前
|
算法 Java 数据中心
探讨面试常见问题雪花算法、时钟回拨问题,java中优雅的实现方式
【10月更文挑战第2天】在大数据量系统中,分布式ID生成是一个关键问题。为了保证在分布式环境下生成的ID唯一、有序且高效,业界提出了多种解决方案,其中雪花算法(Snowflake Algorithm)是一种广泛应用的分布式ID生成算法。本文将详细介绍雪花算法的原理、实现及其处理时钟回拨问题的方法,并提供Java代码示例。
72 2
|
1月前
|
JSON 安全 前端开发
第二次面试总结 - 宏汉科技 - Java后端开发
本文是作者对宏汉科技Java后端开发岗位的第二次面试总结,面试结果不理想,主要原因是Java基础知识掌握不牢固,文章详细列出了面试中被问到的技术问题及答案,包括字符串相关函数、抽象类与接口的区别、Java创建线程池的方式、回调函数、函数式接口、反射以及Java中的集合等。
29 0
|
3月前
|
XML 存储 JSON
【IO面试题 六】、 除了Java自带的序列化之外,你还了解哪些序列化工具?
除了Java自带的序列化,常见的序列化工具还包括JSON(如jackson、gson、fastjson)、Protobuf、Thrift和Avro,各具特点,适用于不同的应用场景和性能需求。
下一篇
无影云桌面