String s = new String("Test");
does not put the object in String pool , we need to call String.intern() method which is used to put them into String pool explicitly. its only when you create String object as String literal e.g. String s = "Test" Java automatically put that into String pool.
There is a difference when looking at exception handling. If your tasks throws an exception and if it was submitted with execute this exception will go to the uncaught exception handler (when you don't have provided one explicitly, the default one will just print the stack trace to System.err). If you submitted the task with submit any thrown exception, checked exception or not, is then part of the task's return status. For a task that was submitted with submit and that terminates with an exception, the Future.get will re-throw this exception, wrapped in an ExecutionException.
@Raj suggested
Abstract Factory provides one more level of abstraction. Consider different factories each extended from an Abstract Factory and responsible for creation of different hierarchies of objects based on the type of factory. E.g. AbstractFactory extended by AutomobileFactory, UserFactory, RoleFactory etc. Each individual factory would be responsible for creation of objects in that genre.
12. Can you write code for iterating over hashmap in Java 4 and Java 5 ?
Tricky one but he managed to write using while and for loop.
13. When do you override hashcode and equals() ?
Whenever necessary especially if you want to do equality check or want to use your object as key in HashMap. check this for writing equals method correctly 5 tips on equals in Java
14. What will be the problem if you don't override hashcode() method ?
You will not be able to recover your object from hash Map if that is used as key in HashMap.
See here How HashMap works in Java for detailed explanation.
15. Is it better to synchronize critical section of getInstance() method or whole getInstance() method ?
Answer is critical section because if we lock whole method than every time some one call this method will have to wait even though we are not creating any object)
16. What is the difference when String is gets created using literal or new() operator ?
When we create string with new() its created in heap and not added into string pool while String created using literal are created in String pool itself which exists in Perm area of heap.
17. Does not overriding hashcode() method has any performance implication ?
This is a good question and open to all , as per my knowledge a poor hashcode function will result in frequent collision in HashMap which eventually increase time for adding an object into Hash Map.
18. What’s wrong using HashMap in multithreaded environment? When get() method go to infinite loop ?
Another good question. His answer was during concurrent access and re-sizing.
19. Give a simplest way to find out the time a method takes for execution without using any profiling tool?
this questions is suggested by @Mohit
Read the system time just before the method is invoked and immediately after method returns. Take the time difference, which will give you the time taken by a method for execution.
To put it in code…
long start = System.currentTimeMillis ();
method ();
long end = System.currentTimeMillis ();
System.out.println (“Time taken for execution is ” + (end – start));
Remember that if the time taken for execution is too small, it might show that it is taking zero milliseconds for execution. Try it on a method which is big enough, in the sense the one which is doing considerable amout of processing
Read more: http://javarevisited.blogspot.com/2011/04/top-20-core-java-interview-questions.html#ixzz2fsjk9vby
相关推荐
从国外网站上下载的Java面试题。可以看看国外公司的Java面试常用题,以及如何用英文回答。
previous forum (read only): http://answers.opencv.org Issue tracking: https://github.com/opencv/opencv/issues Additional OpenCV functionality: https://github.com/opencv/opencv_contrib
previous forum (read only): http://answers.opencv.org Issue tracking: https://github.com/opencv/opencv/issues Additional OpenCV functionality: https://github.com/opencv/opencv_contrib
根据提供的文件信息,本文将对其中涉及的C++面试题目进行详细解析,并提供相应的答案,旨在帮助准备参加C++职位面试的求职者更好地理解和掌握相关的技术要点。 ### 1. C++基础知识 #### 1.1 什么是C++?...
本书《Java Coding Interview》旨在帮助读者在面试过程中取得优异的成绩,传授给求职者必要的面试准备知识。作者有着指导和面试过数百名软件工程师的经验,本书的面试题目是真实的,不仅来自于真实公司的面试问题,...
### IT面试问题与答案解析 #### 1. 如何描述自己? **优秀示例回答:** 我的背景至今一直围绕着成为一名最优秀的财务顾问而努力。让我具体介绍一下我是如何准备自己的。我是一名在______大学主修金融和会计的本科...
115-Java-Interview-Questions-and-Answers, 115 Java访谈问题和答案- 终极列表 #115-Java-Interview-Questions-and-Answers我们将讨论关于Java面试中可以使用的各种问题,以便雇主在Java和面向对象编程方面测试你的...
不管你是新程序员还是...注:本文档根据http://www.importnew.com/12773.html 和http://ifeve.com/java-multi-threading-concurrency-interview-questions-with-answers/ 这两个网站的并发编程试题集整理得到的文档,
根据提供的文件信息,我们可以从中提炼出三个重要的面试问题及其回答策略。这不仅是对求职者面试技巧的考验,也是展示个人专业素养与职业态度的关键时刻。接下来,我们将详细解析这三个问题及如何给出恰当的回答。...
Haldane's Best Answers to Tough Interview Questions 面试常见问题应对
### Java Interview Questions and Answers #### 1. 什么是 Java?解释其含义与定义。 Java 是当今最流行的编程语言之一,在 Web 应用程序、移动应用、软件开发、游戏系统以及服务器端技术等领域扮演着重要角色。...
- **问题链接**:[https://club.kdcloud.com/questions/96970831732907008/answers/97027803266381824](https://club.kdcloud.com/questions/96970831732907008/answers/97027803266381824) - **描述**:此问答详细...
4. **订单创建时弹出窗口(Popup in Order Creation)** 5. **比例价格条件(Scale Price Condition)** 6. **VPRS未复制到开票文档(VPRS Not Copied to Billing Document)** 7. **交付单中的序列号(Serial Numbers in ...
All technical answers asked privately will be automatically answered on the list and archived for public access unless pricacy is explicitely required and justified. Daniel Veillard $Id: README,v ...
SAP Basis Interview Questions 在进行 SAP Basis 的面试准备时,面试官通常会关注应聘者对 SAP Basis 的基础知识和实践经验的理解。例如: - **问题示例**:“请简要介绍 SAP Basis 并解释它的主要功能。” - **...
本资料“Java-Spring-Boot-Interview-Questions-and-Answers”集合了最受欢迎的Java及Spring Boot面试问题,帮助求职者准备相关面试。 一、Java基础 1. 讲解Java内存模型(JVM)的结构,包括堆内存、栈内存、方法区...
### SQL面试题与解答知识点详解 #### 一、关系型数据库管理系统(RDBMS) **定义:** 关系型数据库管理系统(Relational Database Management System,简称RDBMS)是一种用于存储和管理数据的软件系统,它将数据...
本压缩包"Java_Interview_Questions.zip_answers"包含了针对Java面试的一系列问题和答案,旨在帮助准备面试的开发者深入理解Java的核心概念和技术。 1. **基础概念** - **Java是什么?** Java是一种广泛使用的面向...
平均问题(和答案) 今天,我们将首次体验MEAN堆栈:猫鼬,Express,Angular,Node。 我们已经完成了服务器端Mongo / Express / Node和客户端Angular。.../api/questions/:questionId/answers/:id 更新