Most languages have a built in sort method that will sort an array of strings alphabetically. Demonstrate how to sort an array of strings by the length of each string, shortest strings first.
Java Language Features Interview Questions
Define the following object oriented concepts:
- Class, object (and the difference between the two)
- Instantiation
- Method (as opposed to, say, a C function)
- Static methods and classes
- Destructor/finalizer
- Inheritance
- Encapsulation
- Multiple inheritance (and give an example)
- Abstract class
- Interface/protocol (and different from abstract class)
- Method overriding
- Method overloading (and difference from overriding)
- Polymorphism (without resorting to examples)
- Method visibility (e.g. public/private/other)
How many ways can an argument be passed to a method. Explain each method.
What are different types of access modifiers? Explain what they do.
Explain final, finalize() and finally?
Explain what Garbage Collection does. How is it normally initiated? How could you force it to run? What problems can it cause?
Explain the difference between method overloading and method overriding
Explain thedifference between this() and super()
Name 3 top level class modifiers.
Explain the difference between an inner class and an anonymous class? When would you use these?
Explain what reflection is in Java and give an example of when you might use it.
What is an interface in Java? Give and example of where you might use one. How does this compare to inheritance?
Explain the difference between Integer and int in Java and when you would choose to use one over the other.
Can an inner class be defined inside a method? What variables can be accessed by that class?
Explain the terms static, final, and const
What is a Final class and where might you use one?