# Java Questions and Problems ## Java Standard Edition (Java SE) Questions * The String class is immutable. What does this mean and what are the implications in multi-threaded programming? * Why must you write `s = s.trim();` and not simply `s.trim();`? * What are the sizes (in bits) of the following six primitive types: byte, short, int, long, float, double, and char? * Discuss various design patterns you have used. What works for you? * Describe the Model-View-Controller pattern (or the related Observer/Observable pattern). * What IDE (Integrated Development Environment) do you use? * Discuss configuration management systems (SVN, GIT) and build management systems (Ant, Maven). Which have you used? * What are some ways that you can access a database from your Java code? Discuss Object-Relational Mapping (ORM). * Who wrote this code?
public boolean question() {
return bb || !bb;
}
* Given an XML schema, how would you create Java object mappings?
* Does Java have multiple (implementation) inheritance?
----
## Java Enterprise Edition (Java EE) Questions
* What does a JavaServer Page (JSP) become inside the web application container (i.e., to what is it converted)?
* HTTP is a stateless protocol. Explain this. How do servlets maintain state?
* What is the difference between a Stateless Session Bean and an Entity Bean? What are the use cases for each?
* Describe the session facade pattern.
* Discuss some Java EE frameworks that you or your organization have used.
----
Prior to the interview process, you may be asked to solve a programming
problem. The following are some sample problems that are interesting from a
programming perspective as they cover not just Java programming, but
algorithms, recursion, error handling, input processing, and output
formatting. You need not be interviewed to try your hand at these. We
welcome ad hoc submissions as well. Have fun!
----
## Fibonacci Series (Coding Problem)
In the 12th century, Leonardo Fibonacci discovered a simple numerical
series. Starting with 0 and 1, each new number in the series is simply the
sum of the two before it.
> 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, . . .
### Problem
Write a class (`Fib.java`) containing a `main` method that, when invoked with a single numeric argument *n*, prints the first *n* Fibonacci numbers.
For example, running java Fib 10 would print the following:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34
The following table gives the output for varying values of *n*.
| Input (n) | Output (System.out) |
|---|---|
| 0 | nothing is printed |
| 1 | 0 |
| 2 | 0, 1 |
| 3 | 0, 1, 1 |
| 10 | 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 |