boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 面试的一些题目
相关主题
basic java question
thread safe Singleton 的几种方法?
what is your opinion in this case?
我脑袋短路,大家来帮一下:
structure in Java??
请问有没有generic的array
Interview的人问我最新java 版本是多少
extending generic class , but not mentioning its parameterized type?
菜鸟问关于Java Programming的问题
generics这样改对马?
相关话题的讨论汇总
话题: myclass话题: sclass话题: static话题: java话题: class
进入Java版参与讨论
1 (共1页)
s*******e
发帖数: 3042
1
好多年没面试了,最近去了几个面试,java还好,都是正常题目,倒是有两个oracle的
题目,当时
听了就不会,不知道是不是自己水平太逊。一个是讲讲connectby的用法,一个讲讲
merge的用法。
我想了想,connectby实在没印象,merge倒是见过,从来没仔细研究过,只好坦白说,
不会,现在
也没接到电话,估计挂了。
记得的一些java题目(和我的答案,不一定都对,不过interviewer也没说什么)
1. a server is performing extremely slow, what
would be the quickest way to find if too many threads are contending for
the same resource without restarting the server? (answer: take a thread
dump and eyeball the output, or use visualization tool on the output,
either is OK)
2. what is er
g**e
发帖数: 6127
2
谢谢分享。wall st面的java题看起来都差不多,呵呵
这些是电话面试?第七个没听说过,我太土了

【在 s*******e 的大作中提到】
: 好多年没面试了,最近去了几个面试,java还好,都是正常题目,倒是有两个oracle的
: 题目,当时
: 听了就不会,不知道是不是自己水平太逊。一个是讲讲connectby的用法,一个讲讲
: merge的用法。
: 我想了想,connectby实在没印象,merge倒是见过,从来没仔细研究过,只好坦白说,
: 不会,现在
: 也没接到电话,估计挂了。
: 记得的一些java题目(和我的答案,不一定都对,不过interviewer也没说什么)
: 1. a server is performing extremely slow, what
: would be the quickest way to find if too many threads are contending for

s*******e
发帖数: 3042
3
有电话的有当面的,不过总体来说跟java有关的都没什么难度,我比较烦的是那种没什
么用有偏门的
language feature, 我一般会直接告诉他太久不用了,忘了。跟design,performance
tuning
什么有关的也还好,database有点头疼,不知道要准备多少。CAFEBABE知道不知道都无
所谓把,我觉
得就是当八卦聊聊,呵呵。

【在 g**e 的大作中提到】
: 谢谢分享。wall st面的java题看起来都差不多,呵呵
: 这些是电话面试?第七个没听说过,我太土了

g**e
发帖数: 6127
4
曾经被一个老印问过tenure generation和young generation之间object怎么划分和传
递的题,立马歇菜。至今我也没搞清楚

performance

【在 s*******e 的大作中提到】
: 有电话的有当面的,不过总体来说跟java有关的都没什么难度,我比较烦的是那种没什
: 么用有偏门的
: language feature, 我一般会直接告诉他太久不用了,忘了。跟design,performance
: tuning
: 什么有关的也还好,database有点头疼,不知道要准备多少。CAFEBABE知道不知道都无
: 所谓把,我觉
: 得就是当八卦聊聊,呵呵。

g*****g
发帖数: 34805
5
这个如果你要调GC,还是要用到的,Sun的那几个GC算法大致
看看就明白了。

【在 g**e 的大作中提到】
: 曾经被一个老印问过tenure generation和young generation之间object怎么划分和传
: 递的题,立马歇菜。至今我也没搞清楚
:
: performance

s*******e
发帖数: 3042
6
基本上new object在young, survive几轮GC的就从young变成tenured了,以前做server
的时
候一个老年工程师成天跟我们讲这些,不过一直到我离开公司也没觉得这些理论对java
application
提高performance有什么具体的指导,对写VM的人可能有用。
至于怎么传递的,我google了半天也没找到,难道不是mark一下就完了嘛

【在 g**e 的大作中提到】
: 曾经被一个老印问过tenure generation和young generation之间object怎么划分和传
: 递的题,立马歇菜。至今我也没搞清楚
:
: performance

g**e
发帖数: 6127
7
这个基本的我是知道的,也老老实实的说了,不过他当时还问了我几个细节,我就傻了
。然后老印很不屑的就把我打发了...

server
java

【在 s*******e 的大作中提到】
: 基本上new object在young, survive几轮GC的就从young变成tenured了,以前做server
: 的时
: 候一个老年工程师成天跟我们讲这些,不过一直到我离开公司也没觉得这些理论对java
: application
: 提高performance有什么具体的指导,对写VM的人可能有用。
: 至于怎么传递的,我google了半天也没找到,难道不是mark一下就完了嘛

s******e
发帖数: 493
8
http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
should be good enough for all those sick questions and sick people.
g*****g
发帖数: 34805
9
Only good enough for sick people, but not good enough
for sicker people. Fortunately we all need to succeed
in 1 out of N interviews.

【在 s******e 的大作中提到】
: http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
: should be good enough for all those sick questions and sick people.

s******e
发帖数: 493
10
true. this is a topic can warranty a 500 page book.
For a guy sick enough wants you to remmeber every details of this sick topic
, the best way is telling him/her that you think you are wasting time in
there.
相关主题
我脑袋短路,大家来帮一下:
structure in Java??
请问有没有generic的array
Interview的人问我最新java 版本是多少
进入Java版参与讨论
q*********u
发帖数: 280
11
赞分享

好多年没面试了,最近去了几个面试,java还好,都是正常题目,倒是有两个oracle的
题目,当时
听了就不会,不知道是不是自己水平太逊。一个是讲讲connectby的用法,一个讲讲
merge的用法。
我想了想,connectby实在没印象,merge倒是见过,从来没仔细研究过,只好坦白说,
不会,现在
也没接到电话,估计挂了。
记得的一些java题目(和我的答案,不一定都对,不过interviewer也没说什么)
1. a server is performing extremely slow, what
would be the quickest way to find if too many threads are contending for
the same resource without restarting the server? (answer: take a thread
dump and eyeball the output, or use visualization tool on the output,
either is OK)
2. what

【在 s*******e 的大作中提到】
: 好多年没面试了,最近去了几个面试,java还好,都是正常题目,倒是有两个oracle的
: 题目,当时
: 听了就不会,不知道是不是自己水平太逊。一个是讲讲connectby的用法,一个讲讲
: merge的用法。
: 我想了想,connectby实在没印象,merge倒是见过,从来没仔细研究过,只好坦白说,
: 不会,现在
: 也没接到电话,估计挂了。
: 记得的一些java题目(和我的答案,不一定都对,不过interviewer也没说什么)
: 1. a server is performing extremely slow, what
: would be the quickest way to find if too many threads are contending for

c*****t
发帖数: 1879
12

Comparing to eager initiation, the drawback is merely an extra
comparison. Check-and-check again paradigm makes sure that only
the initation part takes extra sync.
inner class final static variable approach further eliminates this
problem. Inner class is loaded only when it is actually being
accessed.

【在 s*******e 的大作中提到】
: 基本上new object在young, survive几轮GC的就从young变成tenured了,以前做server
: 的时
: 候一个老年工程师成天跟我们讲这些,不过一直到我离开公司也没觉得这些理论对java
: application
: 提高performance有什么具体的指导,对写VM的人可能有用。
: 至于怎么传递的,我google了半天也没找到,难道不是mark一下就完了嘛

f******a
发帖数: 30
13
我们公司招java programmer 出这么一个题
You are given an array of names in String form. Names may repeat in the
array. Write a segment of java code or a method that iterates through the
list and print out the number of occurrences for each Name.
for example: a list of names "alan", "ben", "alan", "carl", "carl", "alan",
"jean" should output result "alan" = 3, "ben'=1, "carl" =2, "jean" =1.
You can use the following method template
public void showNameCount(String[] name_array)
{
}
至今有25个面试者做过,只有四个想到用hashta
s*******e
发帖数: 3042
14
Thanks. check and check again only works in 1.5+ with volatile吧?

【在 c*****t 的大作中提到】
:
: Comparing to eager initiation, the drawback is merely an extra
: comparison. Check-and-check again paradigm makes sure that only
: the initation part takes extra sync.
: inner class final static variable approach further eliminates this
: problem. Inner class is loaded only when it is actually being
: accessed.

m*****m
发帖数: 48
15
mark
y***y
发帖数: 224
16

,
啥公司啊? 还招人不^_^

【在 f******a 的大作中提到】
: 我们公司招java programmer 出这么一个题
: You are given an array of names in String form. Names may repeat in the
: array. Write a segment of java code or a method that iterates through the
: list and print out the number of occurrences for each Name.
: for example: a list of names "alan", "ben", "alan", "carl", "carl", "alan",
: "jean" should output result "alan" = 3, "ben'=1, "carl" =2, "jean" =1.
: You can use the following method template
: public void showNameCount(String[] name_array)
: {
: }

q*********u
发帖数: 280
17
顶到十大了

【在 y***y 的大作中提到】
:
: ,
: 啥公司啊? 还招人不^_^

s***8
发帖数: 1136
18

,
this is a good one

【在 f******a 的大作中提到】
: 我们公司招java programmer 出这么一个题
: You are given an array of names in String form. Names may repeat in the
: array. Write a segment of java code or a method that iterates through the
: list and print out the number of occurrences for each Name.
: for example: a list of names "alan", "ben", "alan", "carl", "carl", "alan",
: "jean" should output result "alan" = 3, "ben'=1, "carl" =2, "jean" =1.
: You can use the following method template
: public void showNameCount(String[] name_array)
: {
: }

c*****t
发帖数: 1879
19
Not just 1.5. Also works with prior versions. It purely depends on
your own implementation.

【在 s*******e 的大作中提到】
: Thanks. check and check again only works in 1.5+ with volatile吧?
s*******e
发帖数: 3042
20
you meant something like this?
class MyClass {
private SingletonClass sClass = null;
public SingletonClass getInstance() {
if (sClass == null)
synchronized(this) {
if (sClass == null)
sClass = new SingletonClass();
}
return sClass;
}
....
}
This is the only implementation that I can think of to avoid going
through synchronized block every time, but I don't think it works in 1.4
and before

【在 c*****t 的大作中提到】
: Not just 1.5. Also works with prior versions. It purely depends on
: your own implementation.

相关主题
extending generic class , but not mentioning its parameterized type?
菜鸟问关于Java Programming的问题
generics这样改对马?
问个 Generic 的问题
进入Java版参与讨论
s******e
发帖数: 493
21
It won't even work for 1.5+ without volatile keyword.

【在 s*******e 的大作中提到】
: you meant something like this?
: class MyClass {
: private SingletonClass sClass = null;
: public SingletonClass getInstance() {
: if (sClass == null)
: synchronized(this) {
: if (sClass == null)
: sClass = new SingletonClass();
: }
: return sClass;

s*******e
发帖数: 3042
22
yeah sorry I forgot to put volatile

【在 s******e 的大作中提到】
: It won't even work for 1.5+ without volatile keyword.
q*********u
发帖数: 280
23
有几个题还是不太明白
2.What is erasure of Generics
这个what 是不是改成when比较好,因为你的答案里面有一个when compiling java
source to bytecode, then jvm remove the type of generics
5. drawbacks of lazy initialization
不太明白你的答案,能不能解释一下
第11题的话,你的pass by value的确是太安慰我了,不过个人觉得面试的时候,直
接笼统的说pass by value,应该有些补充,比如:
public class XXX{
...
public static void method(A a){
//进入函数后,调用的函数中的参数会被copy, 那么内存中起码有2个指向a
的ref,所以说,本质上是pass by value 没有错。
a.setVar(...); //可以改变a所指向的对象A的值
a = new A(); //这个时候,a 就指向另外一个新建的A了,和函数外的对象
A脱离了;

【在 s*******e 的大作中提到】
: 好多年没面试了,最近去了几个面试,java还好,都是正常题目,倒是有两个oracle的
: 题目,当时
: 听了就不会,不知道是不是自己水平太逊。一个是讲讲connectby的用法,一个讲讲
: merge的用法。
: 我想了想,connectby实在没印象,merge倒是见过,从来没仔细研究过,只好坦白说,
: 不会,现在
: 也没接到电话,估计挂了。
: 记得的一些java题目(和我的答案,不一定都对,不过interviewer也没说什么)
: 1. a server is performing extremely slow, what
: would be the quickest way to find if too many threads are contending for

c*****t
发帖数: 1879
24
sigh, singleton lazy initiation method is this
public class MyClass
{
private final static class MyClassSingletonHelper
{
final static MyClass s_instance = new MyClass ();
}
public static MyClass getInstance ()
{
return MyClassSingletonHelper.s_instance;
}
private MyClass () { }
...
}
Note, MyClassSingletonHelper is not loaded when MyClass is loaded.
The helper class is loaded only when its member is used.

【在 s*******e 的大作中提到】
: you meant something like this?
: class MyClass {
: private SingletonClass sClass = null;
: public SingletonClass getInstance() {
: if (sClass == null)
: synchronized(this) {
: if (sClass == null)
: sClass = new SingletonClass();
: }
: return sClass;

q*********u
发帖数: 280
25
恩,
lazy的好处容易讲,
不过原帖里面讲做为drawback, 需要多添加更多的synchronized block, 其实就算
不是lazy, 需要syn的时候,还是得一样外加syn block
我理解是如果有许多singlton需要在强调performance 的地方被第一次调用出来,这样
的话,应该是增加程序局部关键处的开销。

sigh, singleton lazy initiation method is this
public class MyClass
{
private final static class MyClassSingletonHelper
{
final static MyClass s_instance = new MyClass ();
}
public static MyClass getInstance ()
{
return MyClassSingletonHelper.s_instance;
}
private MyClass () { }
.

【在 c*****t 的大作中提到】
: sigh, singleton lazy initiation method is this
: public class MyClass
: {
: private final static class MyClassSingletonHelper
: {
: final static MyClass s_instance = new MyClass ();
: }
: public static MyClass getInstance ()
: {
: return MyClassSingletonHelper.s_instance;

1 (共1页)
进入Java版参与讨论
相关主题
generics这样改对马?
问个 Generic 的问题
question: how to implement this
a synchonized problem!
static getInstance()
看到一个关于singleton的面试题
请教一个动态cast的问题
java 依赖注入和反射是必须掌握的吗?
java gc之前有没有办法得到notification?
Re: Question: Java Synchronization
相关话题的讨论汇总
话题: myclass话题: sclass话题: static话题: java话题: class