Java Interview: Checklist

I am listing below the checklist of concepts and keywords in java which are most frequently asked in interview. Please excuse me for presenting it in a random order.

Following are the topics/keywords/concepts which require a crisp knowledge and understanding. These are basisc only.

  • JVM – About JVM, JIT compiler, Bytecode, Classloader
  • Garbage Colection – Conditions when JVM invokes garbage collection, System.gc()
  • Static and Instance initializer block
  • Datatypes – character especially
  • enum – where to declare, defining constructor, methods and variables in enum
  • OOP concepts – inheritance, polymorphism, aggregation vs Composition, abstraction
  • Multiple Inheritance in java
  • Difference/Similarities between interface and abstract class
  • Software Engineering Concepts – Coupling and Cohesion
  • String, StringBuffer and StringBuilder
  • Exception Handling – Checked vs Unchecked Exceptions, Assertion, Error, Exception Hierarchy, throw vs throws
  • final, finally and finalize
  • Method Overriding (Rules for the same)
  • Method Overloading – Covariant Return (Java5)
  • Autoboxing
  • Array – Declaring an anonymous and multidimensional array
  • Keywords like super and this
  • The Object classs – equals and hashcode methods
  • Access Specifiers – default, public , protected and private
  • Marker Interface, Wrapper Classe and Adapter Class
  • Classes like Math, StrictMath, Scanner, Console
  • Java IO: Important classes in IO, NIO.
  • Reading and writing XMLs in java. Type of parsers – SAX, DOM and STAX.
  • Java UI: AWT vs Swing, Different Layouts, Event handling, Calback methods
  • Serialization, Transient keyword
  • Multithreading – Runnable vs Thread, How to write a thread, difference between run and start method.
  • Java5 Concurrency and advanced threading – Callable, Future, Executors, Thread pooling, Locks and Conditions
  • Collection and Generics – Map, Set and List; Conventional Questions like ArrayList vs Vector, HashTable vs HashMap etc; Comparator and Comparable; Important collection classes.
  • Methods of java.util.Collections – Synchronizing a collection, Creating views
  • JDBC: The JDBC code, Type of JDBC Drivers, Type of Statements, execute, executeUpdate and executeQuery

We can discuss these further in case of queries/suggestions. Feel free to comment and add in case I missed something.

Enjoy learning,

Kamlesh

Java Facts: Multiple Inheritance

“Does Java Support Multiple Inheritance?” This is one of the most favorite java interview questions.

Whenever this question is asked the most common (and sometimes expected) answers are:

“No” or

“Well! Java does support multiple inheritance but with the interfaces not the classes.”

Both the answers are correct and accepted.

However we can find a better answer of the same question if we go by what the Java Specification has to say:

Classes support single implementation inheritance, in which the implementation

of each class is derived from that of a single superclass, and ultimately from

the class Object.”

“Multiple interface inheritance is supported.”

The term ‘implementation inheritance’ may be confused with the keyword implements, which is incorrect. Implementation inheritance means a class can inherit (using the keyword extends) only one super class.e.g.

Incorrect: public class Derived extends Base1, Base2

Correct:  public class Derived extends Base

On the other hand Interface Inheritance implies that a class can implement multiple interfaces (using implements keyword) and an interface can extend multiple interfaces (using extends keyword).

Correct: public class Concrete implements A, B

Correct: public interface C extends A, B

Incorrect: public interface C implements A, B

The concept of inheritance differs from that of C++ in order to avoid the classic diamond problem in C++.

Enjoy Learning,
Kamlesh