Mercury Systems Java面试题

匿名网友 匿名网友 发布于: 2015-08-30 00:00:00
阅读 109 收藏 0 点赞 0 评论 0

CoreJava Test Provide byMercury Systems, Inc.

 

 

 

Part1: Basic Java Concepts (20 credits)

Justifywhether the following statements are TRUE or FALSE.

 

1. (False) An abstract class must have at least one abstract method (Anabstract class can contain abstract method or contain none abstract method).

2. (False) Inheritance shows “is a” relation. (Implement is “is a” relation)

3. (False) We can use try-finally block without catch clause (Try catchblock must collocation).

4. (False) StringBuilder is a thread-safe class (StringBuffer is thread-safeclass).

5. (True) ArrayList has better performance than Vector (Yes. Because Vectorclass is Synchronization, the Vector runs Serialized method ArrayList fasterthan Vector).

6. (True) IOException is an unchecked exception (Yes. IOException is anunchecked exception. If invoke try catch to handling the exception is “CheckedException”, if not invoke to handling the exception will be “UncheckedException”. For example: ClassNotFound is an unchecked exception.).

7. (True) A transient field can not be serialized (Yes. A transient field cannot be serialized. For example: User’s password or bank account will be atransient field can not be serialized send to Internet).

8. (True) A constructor is a method that can only have return type void (Yes.A constructor must return void).

9. (True) We can define public static final void main method (Yes. We candefine public static final void main method. Also we can use synchronized).

10. (False) clone() method in class Object makes a deep copy of an object (clone()method implement a Serializable interface is a deep copy of an object).

 

Part2: Core Java Coding (80 credits)

YouMUST send back the java source file .java that can be complied and run directlyunder Java 5 or 6.

 

Problem #1 (40 credits)

Given astring, design an algorithm in O(n) running time to find the character thatappears more than half of the time in the string. If the character does notexist, output null.

Input:abadacababaaaa

Output: a

Input:abcdeabbad

Output: null

 

Problem #2 (40 credits)

Input an arithmetic expression with ONLY+, -, * and /, parse the expression and calculate the result.

Input: 5.6 / 0.7 * 2 – 3.5

Output: 12.5

Input: -1.3 + 5.1 / 3 – 0.8

Output: -0.4

 

** This test should not take more thanthree hours.

** Please send the test to resource@mercurysystemsinc.com.

评论列表
文章目录