由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Apple Siri 组 Java 测试题
相关主题
问一个java generic的问题讨论一个题目
[google面试]iterator访问一个实际碰到的问题
storm8 online code给跪了combinations 有没有 iterative的方法阿 ?
input a string "hello word", print l:3 o:2 e:1 d:1 h:1 r:1 w:1.不知道哪错了刷了半天题
Dream company Onsite被搞了(少量面经)请教leetcode上的count and say
问个最近面试里的题目问个google面试题
java 求助微软onsite SDET 面经
L家的高频题merge k sorted arrays giving iterators求讨论!Yodle 面试题 Triangle 答对能有面试机会
相关话题的讨论汇总
话题: string话题: iterator话题: return话题: problem话题: integer
进入JobHunting版参与讨论
1 (共1页)
r******r
发帖数: 700
1
/**
* Using {@link AppleExercise.Problem1.SampleCache} as a starting point,
answer questions 1-3 by
* creating 3 new inner classes within {@link AppleExercise.Problem1}
below.
*/
public static class Problem1 {
public interface Cache {
public void put(Object key, Object value);
public Object get(Object key);
}
public static class SampleCache implements Cache {
private Map map;
public SampleCache() {
map = new HashMap();
}
@SuppressWarnings("unchecked")
public void put(Object key, Object value) {
map.put(key, value);
}
public Object get(Object key) {
return map.get(key);
}
}
/**
* Problem 1.1
*
* Re-implement {@link AppleExercise.Problem1.SampleCache} as a
singleton which implements the Cache interface.
* Do not use any @SuppressWarnings annotations, and ensure that
your implementation compiles without warnings
* under Java 1.6.
*
* Name it {@link AppleExercise.Problem1.SingletonCache}
*/
/**
* Problem 1.2
*
* The HashMap class backing the {@link AppleExercise.Problem1.
SampleCache} class is not thread-safe.
* Duplicate and modify your {@link AppleExercise.Problem1.
SingletonCache} implementation to ensure
* that both Cache.put and Cache.get methods are safe to be called
by multi-threads.
* Do not use any @SuppressWarnings annotations, and ensure that
your implementation compiles
* without warnings under Java 1.6.
*
* Name it {@link AppleExercise.Problem1.ThreadSafeCache}
*/
/**
* Problem 1.3
*
* Use Java Generics to implement a non-singleton GenericCache class
to improve compile-time type checking.
*
* Name it {@link AppleExercise.Problem1.GenericCache}
*/
}
/**
* Using any Java 1.6 classes or language features, implement these five
methods.
* Create any helper classes or methods that you think contribute to an
elegant and
* efficient solution.
*
* If you feel like there is more than one solution to the problem,
* implement only the one that you feel is "best", and please explain
* why you think it is a better choice than the alternatives.
* List any assumptions that you made for your best solution.
*/
public static class Problem2 {
/**
* Problem 2.1
*
* Return an Iterator that iterates through of each String in the
order that they are provided,
* but skips {@code null} values.
*
* @param strings an array of nullable values
* @return an iterator of strings
*/
public static Iterator iterateStrings(String... strings) {
// TODO
return null;
}
/**
* Problem 2.2
*
* Return a single Iterator that chains together the array
of Iterators in the order
* that they are provided, but skips {@code null} values.
*
* @param stringIterators an array of nullable {@code Iterator<
String>}s of nullable {@code String}s
* @return an {@link java.util.Iterator} of {@code String}s
*/
public static Iterator iterateStrings(Iterator...
stringIterators) {
// TODO
return null;
}
/**
* Problem 2.3
*
* Return an Iterator that iterates through strings of each String[]
in the order that they are
* provided, but skips {@code null} values.
*
* @param stringArrays an array of nullable {@code String[}s of
nullable {@code String}s
* @return an {@link java.util.Iterator} of {@code String}s
*/
public static Iterator iterateStrings(String[]...
stringArrays) {
// TODO
return null;
}
/**
* Problem 2.4
*
* Return an Iterator that iterates through all Integers within each
two-dimensional Integer array in
* the order that they are provided, but skips {@code null} values.
*
* @param twoDimensionalIntArrays an array of nullable {@code
Integer[][]}s of nullable values
* @return an {@link java.util.Iterator} of {@code Integer}s
*/
public static Iterator iterateInts(Integer[][]...
twoDimensionalIntArrays) {
// TODO
return null;
}
/**
* Problem 2.5
*
* Return an Iterator that iterates through all Integers within each
set in the order that they are
* provided, but skips {@code null} values.
*
* @param integerSetList a list of nullable {@code LinkedHashSet}s
of nullable {@code Integer}s
* @return an {@link java.util.Iterator} of {@code Integer}s
*/
public static Iterator iterateInts2(List Integer>> integerSetList) {
// TODO
return null;
}
/**
* Problem 2.6
*
* Bonus question!
*
* Despite using generics, invoking one of the methods above in
Problem 2 is not guaranteed to be
* type-safe.
*
* Answer the following questions:
*
* a) Which method is it?
*
* b) Does the java compiler let you know? If not, how can you
tell? If so, what warning or error
* will the compiler give you?
*
* c) What can you do to avoid the problem?
*/
}
1 (共1页)
进入JobHunting版参与讨论
相关主题
Yodle 面试题 Triangle 答对能有面试机会Dream company Onsite被搞了(少量面经)
也发面经问个最近面试里的题目
上一道小题java 求助
LRU cache 问题L家的高频题merge k sorted arrays giving iterators求讨论!
问一个java generic的问题讨论一个题目
[google面试]iterator访问一个实际碰到的问题
storm8 online code给跪了combinations 有没有 iterative的方法阿 ?
input a string "hello word", print l:3 o:2 e:1 d:1 h:1 r:1 w:1.不知道哪错了刷了半天题
相关话题的讨论汇总
话题: string话题: iterator话题: return话题: problem话题: integer