Friday, April 20, 2018

Interviews FAQ 1

Here I'm not going to explain detailed overview of questions, it is just main points of FAQs that can be asked and this is a part one.

What are the features of Java ?

  • It is simple (Easy learning curve)
  • Robust (both compiletime/runtime error checking, Memory is managed by itself using Garbage collector)
  • Platform independent
  • High performance (With JVM)
  • Very secure (Java files to class files)

What is a class ?

  • Class is a blueprint of which object is created.
  • We can represent a real world object using a class.

What is an interface ?

  • Interface is a blueprint of a class.
  • Interfaces allow a class to behave like multiple types.

Why do we need interfaces ?

  • Interfaces are mainly used for data abstraction.
  • We can achieve multiple inheritance using interfaces.

What is a Java Bean ?

  • Java bean is a class which follows some conventions. 
  • It has no-arg constructor
  • It is serializable.
  • Its fields can only be accessed by getters and setters
  • Its instance variables are final.

What is a hashcode ?

  • Every object has a hashcode, it is unique number.
  • This is assigned by JVM.
  • Hash related data structures use this. (HashMap, HashList...etc)

What is called Serialization ?

  • This is the process of converting an object into a series of bytes.
  • This is very useful when transferring data, store them in sessions...etc

What is called String pool ?

  • It is a separate area of Heap which consist of String objects.
  • This is maintained by JVM.

Difference between == vs equals() 

  • == are used to compare reference and address.
  • equals() method is used to content comparison. 

Web server vs Application server

  • Application server is the super one.
  • Each application server contains a web server.
  • If you are not satisfied with inbuilt server, you can add another server.

Web serverApplication server
Ex: Tomcat, Jetty, ResinEx: Glassfish, Wildfly, JBoss, WebSphere
Not J2EE compatibleJ2EE compatible
Can be run web applications onlyCan be run both web and enterprise applications
Support for HTML, JSP, Servlets...Support for HTML, JSP, Servlets, EJB, JMS...etc

What is the garbage collector ?

  • Garbage collector is a part of JVM.
  • This is used to manage memory.
  • It runs on its own thread with own algorithm.
  • This will destroy useless data(objects without reference) from memory.

StringBuffer vs StringBuilder

Introduced in Java 1.0Introduced in Java 1.5
Every method is synchronizedNo method is synchronized
At a time only one thread is allow to operate.Multiple threads are allow to operate
Thread safeNot thread safe
Slow performances Fast performances 

What is toString() method ?

  • This is called when we trying to print object reference.
  • In collection framework, StringBuffer, StringBuilder, String class already override the toSting() method. 
  • If we didn't override toString() method, object's class toString() method will be called.

Explain the uses of "final" keyword

  • This can be applied to classes, methods and variables.
  • Final classes cannot be extended.
  • Final methods cannot be overridden.
  • Final variables cannot be changed, they are just constants. 

What is called "ACID" in databases ?

  • A - Atomicity
  • C - Consistency 
  • I  - Isolation
  • D - Durability

To be continued...