Eight Core Java Questions

Please join the discussion of the answers for these questions on Twitter

The answers to each question can be combined for a bonus question at the end.

1.

Which of these is NOT a means of communicating between processes in Core Java. Comment on Twitter

  1. UDP
  2. Pipes/Files
  3. Pass by reference
  4. TCP

2.

Which of these methods of copying an object is the LEAST efficient? Comment on Twitter

  1. Java Serialization
  2. clone()
  3. Copying field by field
  4. Using a builder

3.

Which of these is the lowest amount of time Comment on Twitter

  1. A micro-day
  2. A nano-year
  3. 0.001 seconds
  4. A millsecond
  5. A million nanoseconds
  6. 100 microseconds

4.

This loop doesn’t throw an Exception Comment on Twitter

List<String> words = new ArrayList<>(Arrays.asList("one,two,three".split(",")));
for (String word : words)
  if (word.startsWith("t"))
    words.remove(word);

Because

  1. It’s in proportional font
  2. A thread safety race condition
  3. It is looping over an array
  4. Arrays.asList() cannot be resized
  5. The Iterator first compares the number of iterations against the size

5.

By the time the OpenJDK JVM has started the main() method, roughly how many Strings does it create Comment on Twitter

  1. No strings
  2. 5,000 Strings
  3. 5 Strings
  4. A million strings

6.

The stack trace of a Throwable shows where it was Comment on Twitter

  1. Instantiated
  2. Thrown
  3. On the try line
  4. On the caught line
  5. On the finally line

7.

Which double value can be represented without representation error Comment on Twitter

  1. 1.28
  2. 128.0
  3. 0.1
  4. 3.14159265358979323846

8.

On Linux, if a text file is redirected to standard input, you can read it concurrently by using Comment on Twitter

  1. Horizontal scalability
  2. Calling read() from multiple threads
  3. Stream.parallel()
  4. Adding a REST API
  5. Memory mapping /proc/self/fd/0 and partitioning it

Bonus Question.

Take the answers to the 8 questions above

 _ _ _ _ _ _ _ _ 

As a hexadecimal number, what is it’s significance to the JVM?

To learn more about Hexspeak

We are hiring

If you enjoyed this and would like to help solve difficult problems in low level Java, please consider applying https://chronicle.software/careers/

Comments

Popular posts from this blog

Java is Very Fast, If You Don’t Create Many Objects

Low Latency Microservices, A Retrospective

Unusual Java: StackTrace Extends Throwable