Core Java Interviews

Listed here are areas from which one can possibly expect questions in Java Interviews.
Also I have mentioned some understanding on few important topics.

1. objects
a. polymorphism
b. inheritance
c. encapsulation
d. abstraction

equals() method performs deep checking.
Every class should override this method to perform object equality.

== performs shallow checking. It compares the references.

2. strings
a. string equality
b. immutable

a + b + c = new StringBuffer().append(a).append(b).append(c).toString();

3. exception handling.
a. throwable
b. exceptions and errors
c. checked exceptions
d. overriding exceptions

4. threads
a. wait,notify,notifyall
b. Ready state
c. synchronization
d. sleep
e. interrupt exception


List or Sequence : one item following other
eSet : same value cannot be added twice
Map : Key value pair

Vector : ordered list

5. i/o.
System.out.println : OUT is printStream
new File() does not create a file in file system.

6. Serialization : Persisting an object to a file system.
Persist an object beyond the current application instance.
Marker interface.
Transient variables are not persisted.

7. garbage collection
Object is no longer being referenced in a program.
The heap used by the object can be recycled.
a. system.gc()
b. system.runFinalization()
c. finalize method is called before garbage collection. This method can be used for closing open connections,file i/o.

Algorithims : eg Mark and sweep
Define a set of roots and determining reachability from the roots.
Increasing heap size , less frequency of GB, more duration for GB.

8. jvm

loading : given the class name determine the binary form for the class
linking : verfication, Preparation and Resolution
verification : checks well formedness and semantic reqs of java language and jvm
Preparation : storage
intialization : execute the static intializers for the class and class variable initialization

JVM consists of
1. CLassLoader System
2. Execution Engine
3. Data Areas. : This has a Method Area and Heap. Common for all threads.
Stack is allocated for each thread (local variables are created on stack)

9. servlets
Lifecycle of servlets
Session Tracking
1. URL Rewritting
2. Cookies
3. Hidden form fields
4. Session Mgmt

Single threading model.

Define all instance variable for a servlet in a factory class e.g instance data

Http Servlets
FTP Servlets
Telnet Servlets

10. jsp

11. rmi,ejb
session beans
entity beans
Transaction Mgmt

12. websphere
.ear , .war
web module
ejb module
virtual hosts
server groups
Admin console
Application server
Class loading -- classes , /lib/ext/ , lib/app/ ,
Module visibilty
jvm properties

13. xml
HTML/XML comparision

14. xsl

15. jdbc
16. jndi
17. jms
18. sql, pl/sql


Java Bytecodes : machine instructions for jvm. (.class file). Instructions specify operations and operands.
Architecture independent instructions.
These are interpreted by jvm and converted into native m/c code which is exceuted.

JIT compilers : Intrepret bytecodes and translate the same into m/c native code. These are stored on the m/c
It uses the same for execution.

Abstract classes cannot be Instantiated
Final classes cannot be extended

Signature of the method: Method Name and Aruguments
Overloaded Methods : Same Method Name ( Different arguments), different return type
OverRiding Methods : Same Name,arguments and Return Type. Their access cannot be narrowed.

Class : template for creating objects. Defines state and state
Object : Instance of a class

Objects are bound at Runtime (type of the object reference)
Varaibles are bound at compile time (class of the object reference)

ChecKed Exception : JVM does compile time checking. IO exception. Helps in improving Exception Handling of the program. Reducing the unchecked exception conditions in a program.

&& and : shortcircuit operators : Evaluates only one operand.
& and : boolean operators : Both operands. Also bitwise operators.

Constructors : Invoking default constructor when a constructor() is defined will result in compile time error.